Package org.geotools.graph.build.basic
Class BasicGraphBuilder
Object
BasicGraphBuilder
- All Implemented Interfaces:
GraphBuilder
- Direct Known Subclasses:
BasicDirectedGraphBuilder,BasicLineGraphBuilder,OptGraphBuilder
Basic implementation of GraphBuilder. This implementation of builder creates the graph when the builder is created.
The underlying graph implementation makes copies of the references to the node and edge collections, not copies of
the underlying collections themselves. In this way as nodes and edges are added to the builder, it is reflected in
the built graph.
- Author:
- Justin Deoliveira, Refractions Research Inc, jdeolive@refractions.net
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks for loops in which case it only added the edge to the adjacency list of one of the nodes (both of its nodes are the same node).voidAdds a node to the graph.Builds a new edge for the graph.protected GraphCreates the underlying graph object.Builds a new node for the graph.clone(boolean deep) Returns a clone of the builder.getEdges()Returns the edges belonging to the graph being built.getGraph()Returns the graph being built.getNodes()Returns the nodes belonging to the graph being built.voidimportGraph(Graph g) Constructs a graph builder from a pre built graph.voidremoveEdge(Edge edge) Removes an edge from the graph.voidremoveEdges(Collection edges) Removes a collection of edges from the graph.voidremoveNode(Node node) Removes an node from the graph.voidremoveNodes(Collection nodes) Removes a collection of nodes from the graph.
-
Constructor Details
-
BasicGraphBuilder
public BasicGraphBuilder()Constructs a new empty graph builder.
-
-
Method Details
-
buildNode
Description copied from interface:GraphBuilderBuilds a new node for the graph. This method does not add the new node to the graph, this must be done with the addNode(Node) method.- Specified by:
buildNodein interfaceGraphBuilder- Returns:
- Node The newly built node.
- See Also:
-
buildEdge
Description copied from interface:GraphBuilderBuilds a new edge for the graph. This method does not add the new node to the graph, this must be done with the addEdge(Edge) method.- Specified by:
buildEdgein interfaceGraphBuilder- Parameters:
nodeA- Adjacent node to edge.nodeB- Adjacent node to edge.- Returns:
- Edge the newly built Edge.
- See Also:
-
addNode
Description copied from interface:GraphBuilderAdds a node to the graph.- Specified by:
addNodein interfaceGraphBuilder- Parameters:
node- Node to be added to graph.- See Also:
-
addEdge
Checks for loops in which case it only added the edge to the adjacency list of one of the nodes (both of its nodes are the same node).- Specified by:
addEdgein interfaceGraphBuilder- Parameters:
edge- Edge to be added to graph.- See Also:
-
removeNode
Description copied from interface:GraphBuilderRemoves an node from the graph.- Specified by:
removeNodein interfaceGraphBuilder- Parameters:
node- Node to be removed from graph.- See Also:
-
removeNodes
Description copied from interface:GraphBuilderRemoves a collection of nodes from the graph.- Specified by:
removeNodesin interfaceGraphBuilder- Parameters:
nodes- A collection of nodes to be removed from the graph.- See Also:
-
removeEdge
Description copied from interface:GraphBuilderRemoves an edge from the graph.- Specified by:
removeEdgein interfaceGraphBuilder- Parameters:
edge- Edge to be removed from graph.- See Also:
-
removeEdges
Description copied from interface:GraphBuilderRemoves a collection of edges from the graph.- Specified by:
removeEdgesin interfaceGraphBuilder- Parameters:
edges- Collection of edges to be removed from the graph.- See Also:
-
getGraph
Description copied from interface:GraphBuilderReturns the graph being built.- Specified by:
getGraphin interfaceGraphBuilder- Returns:
- Graph The graph being built.
- See Also:
-
clone
Description copied from interface:GraphBuilderReturns a clone of the builder. A deep clone copies the underlying graph structure, a non deep clone results in an empty builder- Specified by:
clonein interfaceGraphBuilder- Parameters:
deep- Deep or non deep clone.- Returns:
- A graph builder.
- Throws:
Exception- See Also:
-
importGraph
Description copied from interface:GraphBuilderConstructs a graph builder from a pre built graph. The nodes and edges of the existing graph are imported into the builder. Relationships between nodes and edges are assummed to be preexistant.- Specified by:
importGraphin interfaceGraphBuilder- Parameters:
g- A pre built graph.- See Also:
-
getNodes
Returns the nodes belonging to the graph being built.- Returns:
- A collection of nodes.
-
getEdges
Returns the edges belonging to the graph being built.- Returns:
- A collection of edges.
-
buildGraph
Creates the underlying graph object.- Returns:
- A Graph object.
-