Class NetworkBuilder<N,E>

  • Type Parameters:
    N - The most general node type this builder will support. This is normally Object unless it is constrained by using a method like nodeOrder(com.google.common.graph.ElementOrder<N1>), or the builder is constructed based on an existing Network using from(Network).
    E - The most general edge type this builder will support. This is normally Object unless it is constrained by using a method like edgeOrder, or the builder is constructed based on an existing Network using from(Network).

    @Beta
    public final class NetworkBuilder<N,E>
    extends Object
    A builder for constructing instances of MutableNetwork or ImmutableNetwork with user-defined properties.

    A network built by this class will have the following properties by default:

    Examples of use:

    
     // Building a mutable network
     MutableNetwork<String, Integer> network =
         NetworkBuilder.directed().allowsParallelEdges(true).build();
     flightNetwork.addEdge("LAX", "ATL", 3025);
     flightNetwork.addEdge("LAX", "ATL", 1598);
     flightNetwork.addEdge("ATL", "LAX", 2450);
    
     // Building a immutable network
     ImmutableNetwork<String, Integer> immutableNetwork =
         NetworkBuilder.directed()
             .allowsParallelEdges(true)
             .<String, Integer>immutable()
             .addEdge("LAX", "ATL", 3025)
             .addEdge("LAX", "ATL", 1598)
             .addEdge("ATL", "LAX", 2450)
             .build();
     
    Since:
    20.0
    Author:
    James Sexton, Joshua O'Madadhain