Class ImmutableDoubleValueGraphAdapter<V>
java.lang.Object
org.jgrapht.graph.AbstractGraph<V, com.google.common.graph.EndpointPair<V>>
org.jgrapht.graph.guava.BaseValueGraphAdapter<V, Double, com.google.common.graph.ImmutableValueGraph<V,Double>>
org.jgrapht.graph.guava.ImmutableValueGraphAdapter<V,Double>
org.jgrapht.graph.guava.ImmutableDoubleValueGraphAdapter<V>
- Type Parameters:
V- the graph vertex type
- All Implemented Interfaces:
Serializable, Cloneable, Graph<V, com.google.common.graph.EndpointPair<V>>
A graph adapter class using Guava's
ImmutableValueGraph specialized with double values.
The adapter uses class EndpointPair to represent edges. Since the underlying value graph
is immutable, the resulting graph is unmodifiable.
Each edge in ImmutableValueGraph is associated with a double value which is mapped to the
edge weight in the resulting Graph. Thus, the graph is weighted and calling method
Graph.getEdgeWeight(Object) will return the value of an edge.
See the example below on how to create such an adapter:
MutableValueGraph<String, Double> mutableValueGraph =
ValueGraphBuilder.directed().allowsSelfLoops(true).build();
mutableValueGraph.addNode("v1");
mutableValueGraph.addNode("v2");
mutableValueGraph.putEdgeValue("v1", "v2", 3.0);
ImmutableValueGraph<String, Double> immutableValueGraph = ImmutableValueGraph.copyOf(mutableValueGraph);
Graph<String, EndpointPair<String>> graph = new ImmutableDoubleValueGraphAdapter<>(immutableValueGraph);
System.out.println(graph.getEdgeWeight(EndpointPair.ordered("v1", "v2")); // outputs 3.0
- See Also:
-
Field Summary
FieldsFields inherited from class ImmutableValueGraphAdapter
GRAPH_IS_IMMUTABLEFields inherited from class BaseValueGraphAdapter
edgeSupplier, LOOPS_NOT_ALLOWED, unmodifiableEdgeSet, unmodifiableVertexSet, valueConverter, valueGraph, vertexOrder, vertexOrderMethod, vertexSupplierFields inherited from interface Graph
DEFAULT_EDGE_WEIGHT -
Constructor Summary
ConstructorsConstructorDescriptionImmutableDoubleValueGraphAdapter(com.google.common.graph.ImmutableValueGraph<V, Double> valueGraph) Create a new adapter. -
Method Summary
Methods inherited from class ImmutableValueGraphAdapter
addEdge, addEdge, addVertex, addVertex, clone, getType, removeEdge, removeEdge, removeVertex, setEdgeWeightMethods inherited from class BaseValueGraphAdapter
containsEdge, containsVertex, createEdge, createVertexOrder, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getVertexSupplier, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, setEdgeSupplier, setVertexSupplier, vertexSetMethods inherited from class AbstractGraph
assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSetsMethods inherited from interface Graph
containsEdge, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getVertexSupplier, incomingEdgesOf, inDegreeOf, iterables, outDegreeOf, outgoingEdgesOf, removeAllEdges, removeAllEdges, removeAllVertices, setEdgeWeight, vertexSet
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
ImmutableDoubleValueGraphAdapter
-