Interface IndexGraphFactory

  • All Superinterfaces:
    GraphFactory<Integer,​Integer>, IntGraphFactory

    public interface IndexGraphFactory
    extends IntGraphFactory
    A factory for Index graphs.

    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 IndexGraphBuilder are 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 IntGraphFactory for IndexGraph.

    Author:
    Barak Ugav
    See Also:
    newDirected(), newUndirected(), IndexGraph, IndexGraphBuilder
    • Method Detail

      • newCopyOf

        default IndexGraph newCopyOf​(Graph<Integer,​Integer> g)
        Description copied from interface: GraphFactory
        Create 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 (if GraphFactory.allowSelfEdges(boolean) was not called with true), attempting to create a copy of a graph that does contains self edges will result in an exception.

        Specified by:
        newCopyOf in interface GraphFactory<Integer,​Integer>
        Specified by:
        newCopyOf in interface IntGraphFactory
        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

        IndexGraph newCopyOf​(Graph<Integer,​Integer> g,
                             boolean copyWeights)
        Description copied from interface: GraphFactory
        Create 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 (if GraphFactory.allowSelfEdges(boolean) was not called with true), attempting to create a copy of a graph that does contains self edges will result in an exception.

        Specified by:
        newCopyOf in interface GraphFactory<Integer,​Integer>
        Specified by:
        newCopyOf in interface IntGraphFactory
        Parameters:
        g - the original graph to copy
        copyWeights - if true, 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

        IndexGraphBuilder newBuilder()
        Description copied from interface: GraphFactory
        Create 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:
        newBuilder in interface GraphFactory<Integer,​Integer>
        Specified by:
        newBuilder in interface IntGraphFactory
        Returns:
        a new graph builder with the factory parameters
      • newUndirected

        static IndexGraphFactory newUndirected()
        Create an undirected index graph factory.
        Returns:
        a new factory that can build undirected index graphs
      • newDirected

        static IndexGraphFactory newDirected()
        Create a directed index graph factory.
        Returns:
        a new factory that can build directed index graphs
      • newFrom

        static IndexGraphFactory newFrom​(IndexGraph g)
        Create a new index graph factory based on a given implementation.

        The new factory will build graphs with the same capabilities 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 IndexGraph.copy() or newCopyOf(Graph).

        Parameters:
        g - a graph from which the factory should copy its capabilities
        Returns:
        a new graph factory that will create graphs with the same capabilities of the given graph
      • setOption

        default IndexGraphFactory 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:
        setOption in interface GraphFactory<Integer,​Integer>
        Specified by:
        setOption in interface IntGraphFactory
        Parameters:
        key - the option key
        value - the option value
        Returns:
        this builder