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>

- Direct Known Subclasses:
    DirectedGraphBuilderBase, UndirectedGraphBuilderBase

      public abstract class AbstractGraphBuilder<V,E,G extends Graph<V,E>,B extends AbstractGraphBuilder<V,E,G,B>>
      extends Object

  Base class for builders of `Graph`
  See Also:
    `DirectedGraphBuilderBase`, `UndirectedGraphBuilderBase`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected G` | `graph`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractGraphBuilder(G baseGraph)` Creates a builder based on `baseGraph`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `B` | `addEdge(V source, V target)` Adds an 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 the `sourceGraph` to the graph being built.
    `B` | `addVertex(V vertex)` Adds `vertex` to the graph being built.
    `B` | `addVertices(V... vertices)` Adds each vertex of `vertices` to the graph being built.
    `G` | `build()` Build the graph.
    `UnmodifiableGraph<V,E>` | `buildUnmodifiable()` Build an unmodifiable version 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)` Removes `vertex` from the graph being built, if such vertex exist in graph.
    `B` | `removeVertices(V... vertices)` Removes each vertex of `vertices` from the graph being built, if such vertices exist in graph.
    `protected abstract B` | `self()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### graph

          protected final G extends Graph<V,E> graph

  - ### Constructor Detail

    - #### AbstractGraphBuilder

          public AbstractGraphBuilder(G baseGraph)

      Creates a builder based on `baseGraph`. `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)

      Adds `vertex` to the graph being built.
      Parameters:
        `vertex` - the vertex to add
      Returns:
        this builder object
      See Also:
        `Graph.addVertex(Object)`

    - #### addVertices

          public B addVertices(V... vertices)

      Adds each vertex of `vertices` 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)`

    - #### addEdgeChain

          public 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.
      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 the `sourceGraph` to the graph being built.
      Returns:
        this builder object
      See Also:
        `Graphs.addGraph(Graph, Graph)`

    - #### removeVertex

          public B removeVertex(V vertex)

      Removes `vertex` 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

          public B removeVertices(V... vertices)

      Removes each vertex of `vertices` 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)`

    - #### 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.

    - #### buildUnmodifiable

          public UnmodifiableGraph<V,E> buildUnmodifiable()

      Build an unmodifiable version graph. Calling any method (including this method) on this builder object after calling this method is undefined behaviour.
      Returns:
        the built unmodifiable graph.
      See Also:
        `build()`

Copyright © 2016. All rights reserved.