V - the graph vertex typeE - the graph edge typepublic class MutableNetworkAdapter<V,E> extends BaseNetworkAdapter<V,E,com.google.common.graph.MutableNetwork<V,E>> implements Graph<V,E>, java.lang.Cloneable, java.io.Serializable
MutableNetwork.
Changes in the adapter such as adding or removing vertices and edges are reflected in the underlying network. Example usage:
MutableNetwork<String, DefaultEdge> mutableNetwork =
NetworkBuilder.directed().allowsParallelEdges(true).allowsSelfLoops(true).build();
Graph<String, DefaultEdge> graph = new MutableNetworkAdapter<>(
mutableNetwork, SupplierUtil.createStringSupplier(), SupplierUtil.DEFAULT_EDGE_SUPPLIER);
graph.addVertex("v1");
System.out.println(mutableNetwork.nodes().contains("v1")); // outputs true
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
GRAPH_IS_UNWEIGHTED |
edgeSupplier, LOOPS_NOT_ALLOWED, network, unmodifiableEdgeSet, unmodifiableVertexSet, vertexOrder, vertexOrderMethod, vertexSupplierDEFAULT_EDGE_WEIGHT| Constructor and Description |
|---|
MutableNetworkAdapter(com.google.common.graph.MutableNetwork<V,E> network)
Create a new network adapter.
|
MutableNetworkAdapter(com.google.common.graph.MutableNetwork<V,E> network,
java.util.function.Supplier<V> vertexSupplier,
java.util.function.Supplier<E> edgeSupplier)
Create a new network adapter.
|
MutableNetworkAdapter(com.google.common.graph.MutableNetwork<V,E> network,
java.util.function.Supplier<V> vertexSupplier,
java.util.function.Supplier<E> edgeSupplier,
ElementOrderMethod<V> vertexOrderMethod)
Create a new network adapter.
|
| Modifier and Type | Method and Description |
|---|---|
E |
addEdge(V sourceVertex,
V targetVertex) |
boolean |
addEdge(V sourceVertex,
V targetVertex,
E e) |
V |
addVertex() |
boolean |
addVertex(V v) |
java.lang.Object |
clone()
Returns a shallow copy of this graph instance.
|
boolean |
removeEdge(E e) |
E |
removeEdge(V sourceVertex,
V targetVertex) |
boolean |
removeVertex(V v) |
void |
setEdgeWeight(E 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, vertexSetprotected static final java.lang.String GRAPH_IS_UNWEIGHTED
public MutableNetworkAdapter(com.google.common.graph.MutableNetwork<V,E> network)
network - the mutable networkpublic MutableNetworkAdapter(com.google.common.graph.MutableNetwork<V,E> network, java.util.function.Supplier<V> vertexSupplier, java.util.function.Supplier<E> edgeSupplier)
network - the mutable networkvertexSupplier - the vertex supplieredgeSupplier - the edge supplierpublic MutableNetworkAdapter(com.google.common.graph.MutableNetwork<V,E> network, java.util.function.Supplier<V> vertexSupplier, java.util.function.Supplier<E> edgeSupplier, ElementOrderMethod<V> vertexOrderMethod)
network - the mutable networkvertexSupplier - 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 E removeEdge(V sourceVertex, V targetVertex)
removeEdge in interface Graph<V,E>public boolean removeEdge(E e)
removeEdge in interface Graph<V,E>public boolean removeVertex(V v)
removeVertex in interface Graph<V,E>public void setEdgeWeight(E e, double weight)
setEdgeWeight in interface Graph<V,E>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.