Package org.jgrapht.graph.guava
Class ImmutableGraphAdapter<V>
- java.lang.Object
-
- org.jgrapht.graph.AbstractGraph<V,com.google.common.graph.EndpointPair<V>>
-
- org.jgrapht.graph.guava.BaseGraphAdapter<V,com.google.common.graph.ImmutableGraph<V>>
-
- org.jgrapht.graph.guava.ImmutableGraphAdapter<V>
-
- Type Parameters:
V- the graph vertex type
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,org.jgrapht.Graph<V,com.google.common.graph.EndpointPair<V>>
public class ImmutableGraphAdapter<V> extends BaseGraphAdapter<V,com.google.common.graph.ImmutableGraph<V>> implements org.jgrapht.Graph<V,com.google.common.graph.EndpointPair<V>>, java.lang.Cloneable, java.io.Serializable
A graph adapter class using Guava'sImmutableGraph.The adapter uses class
EndpointPairto represent edges. Since the underlying graph is immutable, the resulting graph is unmodifiable.See the example below on how to create such an adapter:
MutableGraph<String> mutableGraph = GraphBuilder.directed().allowsSelfLoops(true).build(); mutableGraph.addNode("v1"); mutableGraph.addNode("v2"); mutableGraph.addEdge("v1", "v2"); ImmutableGraph<String> immutableGraph = ImmutableGraph.copyOf(mutableGraph); Graph<String, EndpointPair<String>> graph = new ImmutableGraphAdapter<>(immutableGraph);- Author:
- Dimitrios Michail
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringGRAPH_IS_IMMUTABLE-
Fields inherited from class org.jgrapht.graph.guava.BaseGraphAdapter
edgeSupplier, graph, LOOPS_NOT_ALLOWED, unmodifiableEdgeSet, unmodifiableVertexSet, vertexSupplier
-
-
Constructor Summary
Constructors Constructor Description ImmutableGraphAdapter(com.google.common.graph.ImmutableGraph<V> graph)Create a new adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.graph.EndpointPair<V>addEdge(V sourceVertex, V targetVertex)booleanaddEdge(V sourceVertex, V targetVertex, com.google.common.graph.EndpointPair<V> e)VaddVertex()booleanaddVertex(V v)java.lang.Objectclone()Returns a shallow copy of this graph instance.org.jgrapht.GraphTypegetType()booleanremoveEdge(com.google.common.graph.EndpointPair<V> e)com.google.common.graph.EndpointPair<V>removeEdge(V sourceVertex, V targetVertex)booleanremoveVertex(V v)voidsetEdgeWeight(com.google.common.graph.EndpointPair<V> e, double weight)-
Methods inherited from class org.jgrapht.graph.guava.BaseGraphAdapter
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
-
-
-
-
Field Detail
-
GRAPH_IS_IMMUTABLE
protected static final java.lang.String GRAPH_IS_IMMUTABLE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ImmutableGraphAdapter
public ImmutableGraphAdapter(com.google.common.graph.ImmutableGraph<V> graph)
Create a new adapter.- Parameters:
graph- the graph
-
-
Method Detail
-
addEdge
public boolean addEdge(V sourceVertex, V targetVertex, com.google.common.graph.EndpointPair<V> e)
-
addVertex
public V addVertex()
-
addVertex
public boolean addVertex(V v)
-
removeEdge
public com.google.common.graph.EndpointPair<V> removeEdge(V sourceVertex, V targetVertex)
-
removeEdge
public boolean removeEdge(com.google.common.graph.EndpointPair<V> e)
-
removeVertex
public boolean removeVertex(V v)
-
setEdgeWeight
public void setEdgeWeight(com.google.common.graph.EndpointPair<V> e, double weight)
-
getType
public org.jgrapht.GraphType getType()
-
clone
public java.lang.Object clone()
Returns a shallow copy of this graph instance. Neither edges nor vertices are cloned.- Overrides:
clonein classjava.lang.Object- Returns:
- a shallow copy of this graph.
- Throws:
java.lang.RuntimeException- in case the clone is not supported- See Also:
Object.clone()
-
-