@Beta public final class ValueGraphBuilder<N,V> extends Object
MutableValueGraph
with user-defined properties.
A graph built by this class will have the following properties by default:
Graph.nodes()
in the order in which the elements were added
Example of use:
MutableValueGraph<String, Double> graph =
ValueGraphBuilder.undirected().allowsSelfLoops(true).build();
graph.putEdgeValue("San Francisco", "San Francisco", 0.0);
graph.putEdgeValue("San Jose", "San Jose", 0.0);
graph.putEdgeValue("San Francisco", "San Jose", 48.4);
Modifier and Type | Method and Description |
---|---|
ValueGraphBuilder<N,V> |
allowsSelfLoops(boolean allowsSelfLoops)
Specifies whether the graph will allow self-loops (edges that connect a node to itself).
|
<N1 extends N,V1 extends V> |
build()
Returns an empty
MutableValueGraph with the properties of this ValueGraphBuilder . |
static ValueGraphBuilder<Object,Object> |
directed()
Returns a
ValueGraphBuilder for building directed graphs. |
ValueGraphBuilder<N,V> |
expectedNodeCount(int expectedNodeCount)
Specifies the expected number of nodes in the graph.
|
static <N> ValueGraphBuilder<N,Object> |
from(Graph<N> graph)
Returns a
ValueGraphBuilder initialized with all properties queryable from graph . |
<N1 extends N> |
nodeOrder(ElementOrder<N1> nodeOrder)
Specifies the order of iteration for the elements of
Graph.nodes() . |
static ValueGraphBuilder<Object,Object> |
undirected()
Returns a
ValueGraphBuilder for building undirected graphs. |
public static ValueGraphBuilder<Object,Object> directed()
ValueGraphBuilder
for building directed graphs.public static ValueGraphBuilder<Object,Object> undirected()
ValueGraphBuilder
for building undirected graphs.public static <N> ValueGraphBuilder<N,Object> from(Graph<N> graph)
ValueGraphBuilder
initialized with all properties queryable from graph
.
The "queryable" properties are those that are exposed through the Graph
interface,
such as Graph.isDirected()
. Other properties, such as expectedNodeCount(int)
,
are not set in the new builder.
public ValueGraphBuilder<N,V> allowsSelfLoops(boolean allowsSelfLoops)
UnsupportedOperationException
.public ValueGraphBuilder<N,V> expectedNodeCount(int expectedNodeCount)
IllegalArgumentException
- if expectedNodeCount
is negativepublic <N1 extends N> ValueGraphBuilder<N1,V> nodeOrder(ElementOrder<N1> nodeOrder)
Graph.nodes()
.public <N1 extends N,V1 extends V> MutableValueGraph<N1,V1> build()
MutableValueGraph
with the properties of this ValueGraphBuilder
.Copyright © 2010-2016. All Rights Reserved.