Interface IntGraphFactory
-
- All Superinterfaces:
GraphFactory<Integer,Integer>
- All Known Subinterfaces:
IndexGraphFactory
public interface IntGraphFactory extends GraphFactory<Integer,Integer>
A factory forIntGraphobjects.The factory can be used to create new empty graphs, with different options and capabilities. Few methods are available to optimize the graph implementation choice. The factory can also be used to create a copy of an existing graphs, with the same vertices and edges, with/without copying the vertices/edges weights.
Both the graph factory and
IntGraphBuilderare used to create new graphs. The difference is that vertices and edges can be added to the builder, which is then used to construct non empty graphs, while the factory is only used to choose a graph implementation and create an empty graph.This interface is a specific version of
GraphFactoryforIntGraph.- Author:
- Barak Ugav
- See Also:
newDirected(),newUndirected(),IntGraph,IntGraphBuilder
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jgalgo.graph.GraphFactory
GraphFactory.Hint
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description IntGraphFactoryaddHint(GraphFactory.Hint hint)Add a hint to this factory.IntGraphFactoryallowParallelEdges(boolean parallelEdges)Determine if graphs built by this factory should be support parallel edges.IntGraphFactoryallowSelfEdges(boolean selfEdges)Determine if graphs built by this factory should be support self edges.IntGraphFactoryexpectedEdgesNum(int expectedEdgesNum)Set the expected number of edges that will exist in the graph.IntGraphFactoryexpectedVerticesNum(int expectedVerticesNum)Set the expected number of vertices that will exist in the graph.IntGraphBuildernewBuilder()Create a new graph builder with the factory parameters.default IntGraphnewCopyOf(Graph<Integer,Integer> g)Create a copy of a given graph, with the same vertices and edges, without copying weights.IntGraphnewCopyOf(Graph<Integer,Integer> g, boolean copyWeights)Create a copy of a given graph, with the same vertices and edges, with/without copying weights.static IntGraphFactorynewDirected()Create a directed int graph factory.static IntGraphFactorynewFrom(IntGraph g)Create a new graph factory based on a given implementation.IntGraphnewGraph()Create a new empty graph.static IntGraphFactorynewUndirected()Create an undirected int graph factory.IntGraphFactoryremoveHint(GraphFactory.Hint hint)Remove a hint from this factory.IntGraphFactorysetDirected(boolean directed)Determine if graphs built by this factory should be directed or not.default IntGraphFactorysetOption(String key, Object value)[TL;DR Don't call me!] Set an option.
-
-
-
Method Detail
-
newGraph
IntGraph newGraph()
Description copied from interface:GraphFactoryCreate a new empty graph.- Specified by:
newGraphin interfaceGraphFactory<Integer,Integer>- Returns:
- a new graph with the factory options
-
newCopyOf
default IntGraph newCopyOf(Graph<Integer,Integer> g)
Description copied from interface:GraphFactoryCreate a copy of a given graph, with the same vertices and edges, without copying weights.An identical copy of the given graph will be created, with the same vertices and edges, without copying the vertices/edges weights. The returned Graph will always be modifiable, with no side affects on the original graph.
Differing from
Graph.copy(), the capabilities of the new graph are determined by the factory configuration, rather than copied from the given graph. Note for example that if the factory chooses to use an implementation that does not (have to) support self edges (ifGraphFactory.allowSelfEdges(boolean)was not called withtrue), attempting to create a copy of a graph that does contains self edges will result in an exception.- Specified by:
newCopyOfin interfaceGraphFactory<Integer,Integer>- Parameters:
g- the original graph to copy- Returns:
- an identical copy of the given graph, with the same vertices and edges, without the original graph weights
-
newCopyOf
IntGraph newCopyOf(Graph<Integer,Integer> g, boolean copyWeights)
Description copied from interface:GraphFactoryCreate a copy of a given graph, with the same vertices and edges, with/without copying weights.An identical copy of the given graph will be created, with the same vertices and edges, with/without copying the vertices/edges weights. The returned Graph will always be modifiable, with no side affects on the original graph.
Differing from
Graph.copy(boolean), the capabilities of the new graph are determined by the factory configuration, rather than copied from the given graph. Note for example that if the factory chooses to use an implementation that does not (have to) support self edges (ifGraphFactory.allowSelfEdges(boolean)was not called withtrue), attempting to create a copy of a graph that does contains self edges will result in an exception.- Specified by:
newCopyOfin interfaceGraphFactory<Integer,Integer>- Parameters:
g- the original graph to copycopyWeights- iftrue, the weights of the vertices and edges will be copied to the new graph- Returns:
- an identical copy of the given graph, with the same vertices and edges, with/without the original graph weights
-
newBuilder
IntGraphBuilder newBuilder()
Description copied from interface:GraphFactoryCreate a new graph builder with the factory parameters.The created builder can be used to add vertices and edges, and then build a (mutable or immutable) non empty graph, differing from the factory which only builds empty graphs. The capabilities such as un/directed, support of self edges, support of parallel edges, and hints such as expected number of vertices and edges, other hints, etc. are copied from the factory to the builder.
- Specified by:
newBuilderin interfaceGraphFactory<Integer,Integer>- Returns:
- a new graph builder with the factory parameters
-
setDirected
IntGraphFactory setDirected(boolean directed)
Description copied from interface:GraphFactoryDetermine if graphs built by this factory should be directed or not.- Specified by:
setDirectedin interfaceGraphFactory<Integer,Integer>- Parameters:
directed- iftrue, graphs built by this factory will be directed- Returns:
- this factory
-
allowSelfEdges
IntGraphFactory allowSelfEdges(boolean selfEdges)
Description copied from interface:GraphFactoryDetermine if graphs built by this factory should be support self edges.- Specified by:
allowSelfEdgesin interfaceGraphFactory<Integer,Integer>- Parameters:
selfEdges- iftrue, graphs built by this factory will support self edges- Returns:
- this factory
-
allowParallelEdges
IntGraphFactory allowParallelEdges(boolean parallelEdges)
Description copied from interface:GraphFactoryDetermine if graphs built by this factory should be support parallel edges.- Specified by:
allowParallelEdgesin interfaceGraphFactory<Integer,Integer>- Parameters:
parallelEdges- iftrue, graphs built by this factory will support parallel edges- Returns:
- this factory
-
expectedVerticesNum
IntGraphFactory expectedVerticesNum(int expectedVerticesNum)
Description copied from interface:GraphFactorySet the expected number of vertices that will exist in the graph.- Specified by:
expectedVerticesNumin interfaceGraphFactory<Integer,Integer>- Parameters:
expectedVerticesNum- the expected number of vertices in the graph- Returns:
- this factory
-
expectedEdgesNum
IntGraphFactory expectedEdgesNum(int expectedEdgesNum)
Description copied from interface:GraphFactorySet the expected number of edges that will exist in the graph.- Specified by:
expectedEdgesNumin interfaceGraphFactory<Integer,Integer>- Parameters:
expectedEdgesNum- the expected number of edges in the graph- Returns:
- this factory
-
addHint
IntGraphFactory addHint(GraphFactory.Hint hint)
Description copied from interface:GraphFactoryAdd a hint to this factory.Hints do not change the behavior of the graphs built by this factory, by may affect performance.
- Specified by:
addHintin interfaceGraphFactory<Integer,Integer>- Parameters:
hint- the hint to add- Returns:
- this factory
-
removeHint
IntGraphFactory removeHint(GraphFactory.Hint hint)
Description copied from interface:GraphFactoryRemove a hint from this factory.Hints do not change the behavior of the graphs built by this factory, by may affect performance.
- Specified by:
removeHintin interfaceGraphFactory<Integer,Integer>- Parameters:
hint- the hint to remove- Returns:
- this factory
-
newUndirected
static IntGraphFactory newUndirected()
Create an undirected int graph factory.- Returns:
- a new factory that can build undirected int graphs
-
newDirected
static IntGraphFactory newDirected()
Create a directed int graph factory.- Returns:
- a new factory that can build directed int graphs
-
newFrom
static IntGraphFactory newFrom(IntGraph g)
Create a new graph factory based on a given implementation.The new factory will build graphs with the same capabilities (inclusive) as the given graph, possibly choosing to use a similar implementation. The factory will NOT copy the graph itself (the vertices, edges and weights), for such use case see
IntGraph.copy()ornewCopyOf(Graph).- Parameters:
g- a graph from which the factory should copy its capabilities (inclusive)- Returns:
- a new graph factory that will create graphs with the same capabilities (inclusive) of the given graph
-
setOption
default IntGraphFactory setOption(String key, Object value)
Description copied from interface:GraphFactory[TL;DR Don't call me!] Set an option.The builder might support different options to customize its implementation. These options never change the behavior of the algorithm, only its internal implementation. The possible options are not exposed as 'public' because they are not part of the API and may change in the future.
These options are mainly for debug and benchmark purposes.
- Specified by:
setOptionin interfaceGraphFactory<Integer,Integer>- Parameters:
key- the option keyvalue- the option value- Returns:
- this builder
-
-