Class ImmutableValueGraph.Builder<N,V>
- java.lang.Object
- 
- com.google.common.graph.ImmutableValueGraph.Builder<N,V>
 
- 
- Enclosing class:
- ImmutableValueGraph<N,V>
 
 public static class ImmutableValueGraph.Builder<N,V> extends Object A builder for creatingImmutableValueGraphinstances, especiallystatic finalgraphs. Example:static final ImmutableValueGraph<City, Distance> CITY_ROAD_DISTANCE_GRAPH = ValueGraphBuilder.undirected() .<City, Distance>immutable() .putEdgeValue(PARIS, BERLIN, kilometers(1060)) .putEdgeValue(PARIS, BRUSSELS, kilometers(317)) .putEdgeValue(BERLIN, BRUSSELS, kilometers(764)) .addNode(REYKJAVIK) .build();Builder instances can be reused; it is safe to call build()multiple times to build multiple graphs in series. Each new graph contains all the elements of the ones created before it.- Since:
- 28.0
 
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableValueGraph.Builder<N,V>addNode(N node)Addsnodeif it is not already present.ImmutableValueGraph<N,V>build()Returns a newly-createdImmutableValueGraphbased on the contents of thisBuilder.ImmutableValueGraph.Builder<N,V>putEdgeValue(EndpointPair<N> endpoints, V value)Adds an edge connectingendpointsif one is not already present, and sets a value for that edge tovalue(overwriting the existing value, if any).ImmutableValueGraph.Builder<N,V>putEdgeValue(N nodeU, N nodeV, V value)Adds an edge connectingnodeUtonodeVif one is not already present, and sets a value for that edge tovalue(overwriting the existing value, if any).
 
- 
- 
- 
Method Detail- 
addNode@CanIgnoreReturnValue public ImmutableValueGraph.Builder<N,V> addNode(N node) Addsnodeif it is not already present.Nodes must be unique, just as Mapkeys must be. They must also be non-null.- Returns:
- this Builderobject
 
 - 
putEdgeValue@CanIgnoreReturnValue public ImmutableValueGraph.Builder<N,V> putEdgeValue(N nodeU, N nodeV, V value) Adds an edge connectingnodeUtonodeVif one is not already present, and sets a value for that edge tovalue(overwriting the existing value, if any).If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected. Values do not have to be unique. However, values must be non-null. If nodeUandnodeVare not already present in this graph, this method will silentlyaddnodeUandnodeVto the graph.- Returns:
- this Builderobject
- Throws:
- IllegalArgumentException- if the introduction of the edge would violate- ValueGraph.allowsSelfLoops()
 
 - 
putEdgeValue@CanIgnoreReturnValue public ImmutableValueGraph.Builder<N,V> putEdgeValue(EndpointPair<N> endpoints, V value) Adds an edge connectingendpointsif one is not already present, and sets a value for that edge tovalue(overwriting the existing value, if any).If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected. If this graph is directed, endpointsmust be ordered.Values do not have to be unique. However, values must be non-null. If either or both endpoints are not already present in this graph, this method will silently addeach missing endpoint to the graph.- Returns:
- this Builderobject
- Throws:
- IllegalArgumentException- if the introduction of the edge would violate- ValueGraph.allowsSelfLoops()
- IllegalArgumentException- if the endpoints are unordered and the graph is directed
 
 - 
buildpublic ImmutableValueGraph<N,V> build() Returns a newly-createdImmutableValueGraphbased on the contents of thisBuilder.
 
- 
 
-