Interface IntGraphBuilder
-
- All Superinterfaces:
GraphBuilder<Integer,Integer>
- All Known Subinterfaces:
IndexGraphBuilder
public interface IntGraphBuilder extends GraphBuilder<Integer,Integer>
A builder for int graphs.The builder is used to construct non-empty int graphs. Differing from
IntGraphFactorywhich create new empty graphs, the builder is used to add vertices and edges before actually creating the graph. This capability is required to create immutable graphs, but can also be used to build mutable graph and may gain a performance boost compared to creating an empty graph and adding the same vertices and edges.This interface is a specific version of
GraphBuilderforIntGraph.- Author:
- Barak Ugav
- See Also:
newUndirected(),newDirected(),IndexGraphBuilder,IntGraphFactory
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description intaddEdge(int source, int target)Add a new edge to the graph.voidaddEdge(int source, int target, int edge)Add a new edge to the graph, with user-chosen identifier.default voidaddEdge(Integer source, Integer target, Integer edge)Deprecated.intaddVertex()Add a new vertex to the graph.voidaddVertex(int vertex)Add a new vertex to the graph, with user-chosen identifier.default voidaddVertex(Integer vertex)Deprecated.IntGraphbuild()Build a new immutable graph with the builder vertices and edges.IntGraphbuildMutable()Build a new mutable graph with the builder vertices and edges.IntSetedges()Get the set of edges that were added to the graph.<T,WeightsT extends IWeights<T>>
WeightsTgetEdgesIWeights(String key)Get the edges weights of some key.default <T,WeightsT extends Weights<Integer,T>>
WeightsTgetEdgesWeights(String key)Get the edges weights of some key.<T,WeightsT extends IWeights<T>>
WeightsTgetVerticesIWeights(String key)Get the vertices weights of some key.default <T,WeightsT extends Weights<Integer,T>>
WeightsTgetVerticesWeights(String key)Get the vertices weights of some key.static IntGraphBuildernewDirected()Create a new builder that builds directed int graphs.static IntGraphBuildernewFrom(IntGraph g)Create a new builder initialized with an existing graph vertices and edges, without copying the weights.static IntGraphBuildernewFrom(IntGraph g, boolean copyWeights)Create a new builder initialized with an existing graph vertices and edges, with/without copying the weights.static IntGraphBuildernewUndirected()Create a new builder that builds undirected graphs.IntSetvertices()Get the set of vertices that were added to the graph.-
Methods inherited from interface com.jgalgo.graph.GraphBuilder
addEdgesWeights, addEdgesWeights, addVerticesWeights, addVerticesWeights, clear, expectedEdgesNum, expectedVerticesNum, getEdgesWeightsKeys, getVerticesWeightsKeys
-
-
-
-
Method Detail
-
vertices
IntSet vertices()
Description copied from interface:GraphBuilderGet the set of vertices that were added to the graph.- Specified by:
verticesin interfaceGraphBuilder<Integer,Integer>- Returns:
- the graph vertices
-
edges
IntSet edges()
Description copied from interface:GraphBuilderGet the set of edges that were added to the graph.- Specified by:
edgesin interfaceGraphBuilder<Integer,Integer>- Returns:
- the graph edges
-
addVertex
int addVertex()
Add a new vertex to the graph.The builder will choose identifier not used for any existing vertex, and will return it. It is also possible to add a new vertex and choose its identifier by using
addVertex(int). Only one ofaddVertex()andaddVertex(int)can be used during the construction of a graph.- Returns:
- the new vertex identifier
-
addVertex
void addVertex(int vertex)
Add a new vertex to the graph, with user-chosen identifier.This function is similar to
addVertex(), but let the user to choose the the identifier of the new vertex. Only one ofaddVertex()andaddVertex(int)can be used during the construction of a graph.- Parameters:
vertex- the new vertex identifier
-
addVertex
@Deprecated default void addVertex(Integer vertex)
Deprecated.Description copied from interface:GraphBuilderAdd a new vertex to the graph.- Specified by:
addVertexin interfaceGraphBuilder<Integer,Integer>- Parameters:
vertex- the new vertex
-
addEdge
int addEdge(int source, int target)Add a new edge to the graph.The builder will choose identifier not used for any existing edge, and will return it. It is also possible to add a new edge and choose its identifier by using
addEdge(int, int, int). Only one ofaddEdge(int, int)andaddEdge(int, int, int)can be used during the construction of a graph.- Parameters:
source- the source vertex of the new edgetarget- the target vertex of the new edge- Returns:
- the new edge identifier
-
addEdge
void addEdge(int source, int target, int edge)Add a new edge to the graph, with user-chosen identifier.This function is similar to
addEdge(int, int), but let the user to choose the identifier of the new edge. Only one ofaddEdge(int, int)andaddEdge(int, int, int)can be used during the construction of a graph.- Parameters:
source- the source vertex of the new edgetarget- the target vertex of the new edgeedge- the identifier of the new edge
-
addEdge
@Deprecated default void addEdge(Integer source, Integer target, Integer edge)
Deprecated.Description copied from interface:GraphBuilderAdd a new edge to the graph.- Specified by:
addEdgein interfaceGraphBuilder<Integer,Integer>- Parameters:
source- the source vertex of the new edgetarget- the target vertex of the new edgeedge- the new edge
-
getVerticesIWeights
<T,WeightsT extends IWeights<T>> WeightsT getVerticesIWeights(String key)
Get the vertices weights of some key.See
IWeightsfor a complete documentation of the weights containers.- Type Parameters:
T- The weight data typeWeightsT- the weights container, used to avoid casts of containers of primitive types such asIWeightsInt,IWeightsDoubleect.- Parameters:
key- key of the weights- Returns:
- vertices weights of the key, or
nullif no container found with the specified key
-
getVerticesWeights
default <T,WeightsT extends Weights<Integer,T>> WeightsT getVerticesWeights(String key)
Description copied from interface:GraphBuilderGet the vertices weights of some key.See
Weightsfor a complete documentation of the weights containers.- Specified by:
getVerticesWeightsin interfaceGraphBuilder<Integer,Integer>- Type Parameters:
T- The weight data typeWeightsT- the weights container, used to avoid casts of containers of primitive types such asWeightsInt,WeightsDoubleect.- Parameters:
key- key of the weights- Returns:
- vertices weights of the key, or
nullif no container found with the specified key
-
getEdgesIWeights
<T,WeightsT extends IWeights<T>> WeightsT getEdgesIWeights(String key)
Get the edges weights of some key.See
IWeightsfor a complete documentation of the weights containers.- Type Parameters:
T- The weight data typeWeightsT- the weights container, used to avoid casts of containers of primitive types such asIWeightsInt,IWeightsDoubleect.- Parameters:
key- key of the weights- Returns:
- edges weights of the key, or
nullif no container found with the specified key
-
getEdgesWeights
default <T,WeightsT extends Weights<Integer,T>> WeightsT getEdgesWeights(String key)
Description copied from interface:GraphBuilderGet the edges weights of some key.See
Weightsfor a complete documentation of the weights containers.- Specified by:
getEdgesWeightsin interfaceGraphBuilder<Integer,Integer>- Type Parameters:
T- The weight data typeWeightsT- the weights container, used to avoid casts of containers of primitive types such asWeightsInt,WeightsDoubleect.- Parameters:
key- key of the weights- Returns:
- edges weights of the key, or
nullif no container found with the specified key
-
build
IntGraph build()
Description copied from interface:GraphBuilderBuild a new immutable graph with the builder vertices and edges.- Specified by:
buildin interfaceGraphBuilder<Integer,Integer>- Returns:
- a new immutable graph with the vertices and edges that were added to the builder.
-
buildMutable
IntGraph buildMutable()
Description copied from interface:GraphBuilderBuild a new mutable graph with the builder vertices and edges.- Specified by:
buildMutablein interfaceGraphBuilder<Integer,Integer>- Returns:
- a new mutable graph with the vertices and edges that were added to the builder.
-
newUndirected
static IntGraphBuilder newUndirected()
Create a new builder that builds undirected graphs.- Returns:
- a new empty builder for undirected graphs
-
newDirected
static IntGraphBuilder newDirected()
Create a new builder that builds directed int graphs.- Returns:
- a new empty builder for directed graphs
-
newFrom
static IntGraphBuilder newFrom(IntGraph g)
Create a new builder initialized with an existing graph vertices and edges, without copying the weights.If the given graph is directed, the new builder will build directed graphs, and similarly for undirected graphs.
- Parameters:
g- a graph- Returns:
- a builder initialized with the given graph vertices and edges, without the original graph vertices/edges weights.
-
newFrom
static IntGraphBuilder newFrom(IntGraph g, boolean copyWeights)
Create a new builder initialized with an existing graph vertices and edges, with/without copying the weights.If the given graph is directed, the new builder will build directed graphs, and similarly for undirected graphs.
- Parameters:
g- a graphcopyWeights- iftrue, the weights of the vertices and edges will be copied to the new graph- Returns:
- a builder initialized with the given graph vertices and edges, with/without the original graph vertices/edges weights.
-
-