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 java.lang.Object
Base class for builders ofGraph
 Author:
 Andrew Chen


Constructor Summary
Constructors Constructor Description AbstractGraphBuilder(G baseGraph)
Creates a builder based onbaseGraph
.

Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description B
addEdge(V source, V target)
Adds an edge to the graph being built.B
addEdge(V source, V target, double weight)
Adds an weighted edge to the graph being built.B
addEdge(V source, V target, E edge)
Adds the specified edge to the graph being built.B
addEdge(V source, V target, E edge, double weight)
Adds the specified weighted edge to the graph being built.B
addEdgeChain(V first, V second, V... rest)
Adds a chain of edges to the graph being built.B
addGraph(Graph<? extends V,? extends E> sourceGraph)
Adds all the vertices and all the edges of thesourceGraph
to the graph being built.B
addVertex(V vertex)
Addsvertex
to the graph being built.B
addVertices(V... vertices)
Adds each vertex ofvertices
to the graph being built.G
build()
Build the graph.Graph<V,E>
buildAsUnmodifiable()
Build an unmodifiable version graph.B
removeEdge(E edge)
Removes the specified edge from the graph.B
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.B
removeVertex(V vertex)
Removesvertex
from the graph being built, if such vertex exist in graph.B
removeVertices(V... vertices)
Removes each vertex ofvertices
from the graph being built, if such vertices exist in graph.protected abstract B
self()



Constructor Detail

AbstractGraphBuilder
public AbstractGraphBuilder(G baseGraph)
Creates a builder based onbaseGraph
.baseGraph
must be mutable. Parameters:
baseGraph
 the graph object to base building on


Method Detail

self
protected abstract B self()
 Returns:
 the
this
object.

addVertex
public B addVertex(V vertex)
Addsvertex
to the graph being built. Parameters:
vertex
 the vertex to add Returns:
 this builder object
 See Also:
Graph.addVertex(Object)

addVertices
@SafeVarargs public final B addVertices(V... vertices)
Adds each vertex ofvertices
to the graph being built. Parameters:
vertices
 the vertices to add Returns:
 this builder object
 See Also:
addVertex(Object)

addEdge
public B addEdge(V source, V target)
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:
Graphs.addEdgeWithVertices(Graph, Object, Object)

addEdge
public B addEdge(V source, V target, E edge)
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:
Graph.addEdge(Object, Object, Object)

addEdgeChain
@SafeVarargs public final B addEdgeChain(V first, V second, V... rest)
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:
addEdge(Object, Object)

addGraph
public B addGraph(Graph<? extends V,? extends E> sourceGraph)
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:
Graphs.addGraph(Graph, Graph)

removeVertex
public B removeVertex(V vertex)
Removesvertex
from the graph being built, if such vertex exist in graph. Parameters:
vertex
 the vertex to remove Returns:
 this builder object
 See Also:
Graph.removeVertex(Object)

removeVertices
@SafeVarargs public final B removeVertices(V... vertices)
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:
removeVertex(Object)

removeEdge
public B 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. Parameters:
source
 source vertex of the edge.target
 target vertex of the edge. Returns:
 this builder object
 See Also:
Graph.removeVertex(Object)

removeEdge
public B removeEdge(E edge)
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:
Graph.removeEdge(Object)

addEdge
public B addEdge(V source, V target, double weight)
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:
Graphs.addEdgeWithVertices(Graph, Object, Object, double)

addEdge
public B addEdge(V source, V target, E edge, double weight)
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:
Graph.addEdge(Object, Object, Object)
,Graph.setEdgeWeight(Object, double)

build
public G 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.

