Package org.jgrapht.graph.guava
Class ImmutableNetworkAdapter<V,E>
- java.lang.Object
-
- org.jgrapht.graph.AbstractGraph<V,E>
-
- org.jgrapht.graph.guava.BaseNetworkAdapter<V,E,com.google.common.graph.ImmutableNetwork<V,E>>
-
- org.jgrapht.graph.guava.ImmutableNetworkAdapter<V,E>
-
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,org.jgrapht.Graph<V,E>
public class ImmutableNetworkAdapter<V,E> extends BaseNetworkAdapter<V,E,com.google.common.graph.ImmutableNetwork<V,E>> implements org.jgrapht.Graph<V,E>, java.lang.Cloneable, java.io.Serializable
A graph adapter class using Guava'sImmutableNetwork.Since the underlying network is immutable, the resulting graph is unmodifiable.
Example usage:
MutableNetwork<String, DefaultEdge> mutableNetwork = NetworkBuilder.directed().allowsParallelEdges(true).allowsSelfLoops(true).build(); mutableNetwork.addNode("v1"); ImmutableNetworkGraph<String, DefaultEdge> immutableNetwork = ImmutableNetwork.copyOf(mutableNetwork); Graph<String, DefaultEdge> graph = new ImmutableNetworkAdapter<>(immutableNetwork);- 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.BaseNetworkAdapter
edgeSupplier, LOOPS_NOT_ALLOWED, network, unmodifiableEdgeSet, unmodifiableVertexSet, vertexSupplier
-
-
Constructor Summary
Constructors Constructor Description ImmutableNetworkAdapter(com.google.common.graph.ImmutableNetwork<V,E> network)Create a new network adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EaddEdge(V sourceVertex, V targetVertex)booleanaddEdge(V sourceVertex, V targetVertex, E e)VaddVertex()booleanaddVertex(V v)java.lang.Objectclone()Returns a shallow copy of this graph instance.doublegetEdgeWeight(E e)org.jgrapht.GraphTypegetType()booleanremoveEdge(E e)EremoveEdge(V sourceVertex, V targetVertex)booleanremoveVertex(V v)voidsetEdgeWeight(E e, double weight)-
Methods inherited from class org.jgrapht.graph.guava.BaseNetworkAdapter
containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, 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, 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
-
-
Method Detail
-
addVertex
public boolean addVertex(V v)
-
removeEdge
public boolean removeEdge(E e)
-
removeVertex
public boolean removeVertex(V v)
-
getEdgeWeight
public double getEdgeWeight(E e)
- Specified by:
getEdgeWeightin interfaceorg.jgrapht.Graph<V,E>- Overrides:
getEdgeWeightin classBaseNetworkAdapter<V,E,com.google.common.graph.ImmutableNetwork<V,E>>
-
setEdgeWeight
public void setEdgeWeight(E 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()
-
-