V - the graph vertex typepublic class MutableGraphAdapter<V> extends BaseGraphAdapter<V,com.google.common.graph.MutableGraph<V>> implements Graph<V,com.google.common.graph.EndpointPair<V>>, java.lang.Cloneable, java.io.Serializable
MutableGraph.
The adapter uses class EndpointPair to represent edges. Changes in the adapter such as
adding or removing vertices and edges are reflected in the underlying graph.
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");
Graph<String, EndpointPair<String>> graph = new MutableGraphAdapter<>(mutableGraph);
edgeSupplier, graph, LOOPS_NOT_ALLOWED, unmodifiableEdgeSet, unmodifiableVertexSet, vertexOrder, vertexOrderMethod, vertexSupplierDEFAULT_EDGE_WEIGHT| Constructor and Description |
|---|
MutableGraphAdapter(com.google.common.graph.MutableGraph<V> graph)
Create a new adapter.
|
MutableGraphAdapter(com.google.common.graph.MutableGraph<V> graph,
java.util.function.Supplier<V> vertexSupplier,
java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier)
Create a new adapter.
|
MutableGraphAdapter(com.google.common.graph.MutableGraph<V> graph,
java.util.function.Supplier<V> vertexSupplier,
java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier,
ElementOrderMethod<V> vertexOrderMethod)
Create a new adapter.
|
| Modifier and Type | Method and Description |
|---|---|
com.google.common.graph.EndpointPair<V> |
addEdge(V sourceVertex,
V targetVertex) |
boolean |
addEdge(V sourceVertex,
V targetVertex,
com.google.common.graph.EndpointPair<V> e)
The provided edge object can either be null or must respect the source and target vertices
that are provided as parameters.
|
V |
addVertex() |
boolean |
addVertex(V v) |
java.lang.Object |
clone()
Returns a shallow copy of this graph instance.
|
boolean |
removeEdge(com.google.common.graph.EndpointPair<V> e) |
com.google.common.graph.EndpointPair<V> |
removeEdge(V sourceVertex,
V targetVertex) |
boolean |
removeVertex(V v) |
void |
setEdgeWeight(com.google.common.graph.EndpointPair<V> e,
double weight) |
containsEdge, containsVertex, createVertexOrder, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getType, getVertexSupplier, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, setEdgeSupplier, setVertexSupplier, vertexSetassertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSetsfinalize, getClass, notify, notifyAll, wait, wait, waitcontainsEdge, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getType, getVertexSupplier, incomingEdgesOf, inDegreeOf, iterables, outDegreeOf, outgoingEdgesOf, removeAllEdges, removeAllEdges, removeAllVertices, setEdgeWeight, vertexSetpublic MutableGraphAdapter(com.google.common.graph.MutableGraph<V> graph)
graph - the graphpublic MutableGraphAdapter(com.google.common.graph.MutableGraph<V> graph, java.util.function.Supplier<V> vertexSupplier, java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier)
graph - the graphvertexSupplier - the vertex supplieredgeSupplier - the edge supplierpublic MutableGraphAdapter(com.google.common.graph.MutableGraph<V> graph, java.util.function.Supplier<V> vertexSupplier, java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier, ElementOrderMethod<V> vertexOrderMethod)
graph - the graphvertexSupplier - the vertex supplieredgeSupplier - the edge suppliervertexOrderMethod - the method used to ensure a total order of the graph vertices. This
is required in order to make edge source/targets be consistent.public boolean addEdge(V sourceVertex, V targetVertex, com.google.common.graph.EndpointPair<V> e)
addEdge in interface Graph<V,com.google.common.graph.EndpointPair<V>>java.lang.IllegalArgumentException - if edge e is not null and the sourceVertex parameter does
not match the node U of the endpoint-pairjava.lang.IllegalArgumentException - if edge e is not null and the targetVertex parameter does
not match the node V of the endpoint-pairpublic V addVertex()
public boolean addVertex(V v)
public com.google.common.graph.EndpointPair<V> removeEdge(V sourceVertex, V targetVertex)
removeEdge in interface Graph<V,com.google.common.graph.EndpointPair<V>>public boolean removeEdge(com.google.common.graph.EndpointPair<V> e)
removeEdge in interface Graph<V,com.google.common.graph.EndpointPair<V>>public boolean removeVertex(V v)
removeVertex in interface Graph<V,com.google.common.graph.EndpointPair<V>>public void setEdgeWeight(com.google.common.graph.EndpointPair<V> e, double weight)
setEdgeWeight in interface Graph<V,com.google.common.graph.EndpointPair<V>>public java.lang.Object clone()
clone in class java.lang.Objectjava.lang.RuntimeException - in case the clone is not supportedObject.clone()Copyright © 2021. All rights reserved.