Interface IntGraphBuilder

    • Method Detail

      • 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 of addVertex() and addVertex(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 of addVertex() and addVertex(int) can be used during the construction of a graph.

        Parameters:
        vertex - the new vertex identifier
      • 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 of addEdge(int, int) and addEdge(int, int, int) can be used during the construction of a graph.

        Parameters:
        source - the source vertex of the new edge
        target - 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 of addEdge(int, int) and addEdge(int, int, int) can be used during the construction of a graph.

        Parameters:
        source - the source vertex of the new edge
        target - the target vertex of the new edge
        edge - the identifier of the new edge
      • getVerticesIWeights

        <T,​WeightsT extends IWeights<T>> WeightsT getVerticesIWeights​(String key)
        Get the vertices weights of some key.

        See IWeights for a complete documentation of the weights containers.

        Type Parameters:
        T - The weight data type
        WeightsT - the weights container, used to avoid casts of containers of primitive types such as IWeightsInt, IWeightsDouble ect.
        Parameters:
        key - key of the weights
        Returns:
        vertices weights of the key, or null if no container found with the specified key
      • getVerticesWeights

        default <T,​WeightsT extends Weights<Integer,​T>> WeightsT getVerticesWeights​(String key)
        Description copied from interface: GraphBuilder
        Get the vertices weights of some key.

        See Weights for a complete documentation of the weights containers.

        Specified by:
        getVerticesWeights in interface GraphBuilder<Integer,​Integer>
        Type Parameters:
        T - The weight data type
        WeightsT - the weights container, used to avoid casts of containers of primitive types such as WeightsInt, WeightsDouble ect.
        Parameters:
        key - key of the weights
        Returns:
        vertices weights of the key, or null if 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 IWeights for a complete documentation of the weights containers.

        Type Parameters:
        T - The weight data type
        WeightsT - the weights container, used to avoid casts of containers of primitive types such as IWeightsInt, IWeightsDouble ect.
        Parameters:
        key - key of the weights
        Returns:
        edges weights of the key, or null if no container found with the specified key
      • getEdgesWeights

        default <T,​WeightsT extends Weights<Integer,​T>> WeightsT getEdgesWeights​(String key)
        Description copied from interface: GraphBuilder
        Get the edges weights of some key.

        See Weights for a complete documentation of the weights containers.

        Specified by:
        getEdgesWeights in interface GraphBuilder<Integer,​Integer>
        Type Parameters:
        T - The weight data type
        WeightsT - the weights container, used to avoid casts of containers of primitive types such as WeightsInt, WeightsDouble ect.
        Parameters:
        key - key of the weights
        Returns:
        edges weights of the key, or null if no container found with the specified key
      • build

        IntGraph build()
        Description copied from interface: GraphBuilder
        Build a new immutable graph with the builder vertices and edges.
        Specified by:
        build in interface GraphBuilder<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: GraphBuilder
        Build a new mutable graph with the builder vertices and edges.
        Specified by:
        buildMutable in interface GraphBuilder<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 graph
        copyWeights - if true, 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.