- java.lang.Object
-
- org.jgrapht.graph.AbstractGraph<V,com.google.common.graph.EndpointPair<V>>
-
- org.jgrapht.graph.guava.BaseValueGraphAdapter<V,W,com.google.common.graph.ImmutableValueGraph<V,W>>
-
- org.jgrapht.graph.guava.ImmutableValueGraphAdapter<V,java.lang.Double>
-
- org.jgrapht.graph.guava.ImmutableDoubleValueGraphAdapter<V>
-
- Type Parameters:
V
- the graph vertex type
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Graph<V,com.google.common.graph.EndpointPair<V>>
public class ImmutableDoubleValueGraphAdapter<V> extends ImmutableValueGraphAdapter<V,java.lang.Double>
A graph adapter class using Guava'sImmutableValueGraph
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 resultingGraph
. Thus, the graph is weighted and calling methodGraph.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
- Author:
- Dimitrios Michail
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.jgrapht.graph.guava.ImmutableValueGraphAdapter
GRAPH_IS_IMMUTABLE
-
Fields inherited from class org.jgrapht.graph.guava.BaseValueGraphAdapter
edgeSupplier, LOOPS_NOT_ALLOWED, unmodifiableEdgeSet, unmodifiableVertexSet, valueConverter, valueGraph, vertexSupplier
-
Fields inherited from interface org.jgrapht.Graph
DEFAULT_EDGE_WEIGHT
-
-
Constructor Summary
Constructors Constructor Description ImmutableDoubleValueGraphAdapter(com.google.common.graph.ImmutableValueGraph<V,java.lang.Double> valueGraph)
Create a new adapter.
-
Method Summary
-
Methods inherited from class org.jgrapht.graph.guava.ImmutableValueGraphAdapter
addEdge, addEdge, addVertex, addVertex, clone, getType, removeEdge, removeEdge, removeVertex, setEdgeWeight
-
Methods inherited from class org.jgrapht.graph.guava.BaseValueGraphAdapter
containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getVertexSupplier, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, setEdgeSupplier, setVertexSupplier, vertexSet
-
Methods inherited from class org.jgrapht.graph.AbstractGraph
assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSets
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jgrapht.Graph
containsEdge, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getVertexSupplier, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, removeAllEdges, removeAllEdges, removeAllVertices, setEdgeWeight, vertexSet
-
-
-
-
Constructor Detail
-
ImmutableDoubleValueGraphAdapter
public ImmutableDoubleValueGraphAdapter(com.google.common.graph.ImmutableValueGraph<V,java.lang.Double> valueGraph)
Create a new adapter.- Parameters:
valueGraph
- the value graph
-
-