Module org.jgrapht.core
Package org.jgrapht.graph.builder
Class AbstractGraphBuilder<V,E,G extends Graph<V,E>,B extends AbstractGraphBuilder<V,E,G,B>>
java.lang.Object
org.jgrapht.graph.builder.AbstractGraphBuilder<V,E,G,B>
- Type Parameters:
V
- the graph vertex typeE
- the graph edge typeG
- type of the resulting graphB
- type of this builder
- Direct Known Subclasses:
GraphBuilder
public abstract class AbstractGraphBuilder<V,E,G extends Graph<V,E>,B extends AbstractGraphBuilder<V,E,G,B>>
extends Object
Base class for builders of
Graph
- Author:
- Andrew Chen
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds an edge to the graph being built.Adds an weighted edge to the graph being built.Adds the specified edge to the graph being built.Adds the specified weighted edge to the graph being built.final B
addEdgeChain
(V first, V second, V... rest) Adds a chain of edges to the graph being built.Adds all the vertices and all the edges of thesourceGraph
to the graph being built.Addsvertex
to the graph being built.final B
addVertices
(V... vertices) Adds each vertex ofvertices
to the graph being built.build()
Build the graph.Build an unmodifiable version graph.removeEdge
(E edge) Removes the specified edge from the graph.removeEdge
(V source, V target) Removes an edge going from source vertex to target vertex from the graph being built, if such vertices and such edge exist in the graph.removeVertex
(V vertex) Removesvertex
from the graph being built, if such vertex exist in graph.final B
removeVertices
(V... vertices) Removes each vertex ofvertices
from the graph being built, if such vertices exist in graph.protected abstract B
self()
-
Field Details
-
graph
-
-
Constructor Details
-
AbstractGraphBuilder
Creates a builder based onbaseGraph
.baseGraph
must be mutable.- Parameters:
baseGraph
- the graph object to base building on
-
-
Method Details
-
self
- Returns:
- the
this
object.
-
addVertex
Addsvertex
to the graph being built.- Parameters:
vertex
- the vertex to add- Returns:
- this builder object
- See Also:
-
addVertices
Adds each vertex ofvertices
to the graph being built.- Parameters:
vertices
- the vertices to add- Returns:
- this builder object
- See Also:
-
addEdge
Adds an edge to the graph being built. The source and target vertices are added to the graph, if not already included.- Parameters:
source
- source vertex of the edge.target
- target vertex of the edge.- Returns:
- this builder object
- See Also:
-
addEdge
Adds the specified edge to the graph being built. The source and target vertices are added to the graph, if not already included.- Parameters:
source
- source vertex of the edge.target
- target vertex of the edge.edge
- edge to be added to this graph.- Returns:
- this builder object
- See Also:
-
addEdgeChain
Adds a chain of edges to the graph being built. The vertices are added to the graph, if not already included.- Parameters:
first
- the first vertexsecond
- the second vertexrest
- the remaining vertices- Returns:
- this builder object
- See Also:
-
addGraph
Adds all the vertices and all the edges of thesourceGraph
to the graph being built.- Parameters:
sourceGraph
- the source graph- Returns:
- this builder object
- See Also:
-
removeVertex
Removesvertex
from the graph being built, if such vertex exist in graph.- Parameters:
vertex
- the vertex to remove- Returns:
- this builder object
- See Also:
-
removeVertices
Removes each vertex ofvertices
from the graph being built, if such vertices exist in graph.- Parameters:
vertices
- the vertices to remove- Returns:
- this builder object
- See Also:
-
removeEdge
Removes an edge going from source vertex to target vertex from the graph being built, if such vertices and such edge exist in the graph.- Parameters:
source
- source vertex of the edge.target
- target vertex of the edge.- Returns:
- this builder object
- See Also:
-
removeEdge
Removes the specified edge from the graph. Removes the specified edge from this graph if it is present.- Parameters:
edge
- edge to be removed from this graph, if present.- Returns:
- this builder object
- See Also:
-
addEdge
Adds an weighted edge to the graph being built. The source and target vertices are added to the graph, if not already included.- Parameters:
source
- source vertex of the edge.target
- target vertex of the edge.weight
- weight of the edge.- Returns:
- this builder object
- See Also:
-
addEdge
Adds the specified weighted edge to the graph being built. The source and target vertices are added to the graph, if not already included.- Parameters:
source
- source vertex of the edge.target
- target vertex of the edge.edge
- edge to be added to this graph.weight
- weight of the edge.- Returns:
- this builder object
- See Also:
-
build
Build the graph. Calling any method (including this method) on this builder object after calling this method is undefined behaviour.- Returns:
- the built graph.
-
buildAsUnmodifiable
Build an unmodifiable version graph. Calling any method (including this method) on this builder object after calling this method is undefined behaviour.- Returns:
- the built unmodifiable graph.
- See Also:
-