V - the graph vertex typeW - the value typeVG - type of the underlying Guava's value graphpublic abstract class BaseValueGraphAdapter<V,W,VG extends com.google.common.graph.ValueGraph<V,W>> extends AbstractGraph<V,com.google.common.graph.EndpointPair<V>> implements Graph<V,com.google.common.graph.EndpointPair<V>>, java.lang.Cloneable, java.io.Serializable
ValueGraph. This
is a helper class in order to support both mutable and immutable value graphs.| Modifier and Type | Field and Description |
|---|---|
protected java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> |
edgeSupplier |
protected static java.lang.String |
LOOPS_NOT_ALLOWED |
protected java.util.Set<com.google.common.graph.EndpointPair<V>> |
unmodifiableEdgeSet |
protected java.util.Set<V> |
unmodifiableVertexSet |
protected java.util.function.ToDoubleFunction<W> |
valueConverter |
protected VG |
valueGraph |
protected org.jgrapht.graph.guava.ElementOrder<V> |
vertexOrder |
protected ElementOrderMethod<V> |
vertexOrderMethod |
protected java.util.function.Supplier<V> |
vertexSupplier |
DEFAULT_EDGE_WEIGHT| Constructor and Description |
|---|
BaseValueGraphAdapter(VG valueGraph,
java.util.function.ToDoubleFunction<W> valueConverter)
Create a new adapter.
|
BaseValueGraphAdapter(VG valueGraph,
java.util.function.ToDoubleFunction<W> valueConverter,
java.util.function.Supplier<V> vertexSupplier,
java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier)
Create a new adapter.
|
BaseValueGraphAdapter(VG valueGraph,
java.util.function.ToDoubleFunction<W> valueConverter,
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 |
|---|---|
boolean |
containsEdge(com.google.common.graph.EndpointPair<V> e) |
boolean |
containsVertex(V v) |
protected org.jgrapht.graph.guava.ElementOrder<V> |
createVertexOrder(ElementOrderMethod<V> vertexOrderMethod)
Create the internal vertex order implementation.
|
int |
degreeOf(V vertex) |
java.util.Set<com.google.common.graph.EndpointPair<V>> |
edgeSet() |
java.util.Set<com.google.common.graph.EndpointPair<V>> |
edgesOf(V vertex) |
java.util.Set<com.google.common.graph.EndpointPair<V>> |
getAllEdges(V sourceVertex,
V targetVertex) |
com.google.common.graph.EndpointPair<V> |
getEdge(V sourceVertex,
V targetVertex) |
V |
getEdgeSource(com.google.common.graph.EndpointPair<V> e) |
java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> |
getEdgeSupplier() |
V |
getEdgeTarget(com.google.common.graph.EndpointPair<V> e) |
double |
getEdgeWeight(com.google.common.graph.EndpointPair<V> e) |
GraphType |
getType() |
java.util.function.Supplier<V> |
getVertexSupplier() |
java.util.Set<com.google.common.graph.EndpointPair<V>> |
incomingEdgesOf(V vertex) |
int |
inDegreeOf(V vertex) |
int |
outDegreeOf(V vertex) |
java.util.Set<com.google.common.graph.EndpointPair<V>> |
outgoingEdgesOf(V vertex) |
void |
setEdgeSupplier(java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier)
Set the edge supplier that the graph uses whenever it needs to create new edges.
|
void |
setVertexSupplier(java.util.function.Supplier<V> vertexSupplier)
Set the vertex supplier that the graph uses whenever it needs to create new vertices.
|
java.util.Set<V> |
vertexSet() |
assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSetsclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddEdge, addEdge, addVertex, addVertex, containsEdge, iterables, removeAllEdges, removeAllEdges, removeAllVertices, removeEdge, removeEdge, removeVertex, setEdgeWeight, setEdgeWeightprotected static final java.lang.String LOOPS_NOT_ALLOWED
protected transient java.util.Set<V> unmodifiableVertexSet
protected transient java.util.Set<com.google.common.graph.EndpointPair<V>> unmodifiableEdgeSet
protected java.util.function.Supplier<V> vertexSupplier
protected java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier
protected java.util.function.ToDoubleFunction<W> valueConverter
protected ElementOrderMethod<V> vertexOrderMethod
protected transient org.jgrapht.graph.guava.ElementOrder<V> vertexOrder
public BaseValueGraphAdapter(VG valueGraph, java.util.function.ToDoubleFunction<W> valueConverter)
valueGraph - the mutable value graphvalueConverter - a function that converts a value to a doublepublic BaseValueGraphAdapter(VG valueGraph, java.util.function.ToDoubleFunction<W> valueConverter, java.util.function.Supplier<V> vertexSupplier, java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier)
valueGraph - the mutable value graphvalueConverter - a function that converts a value to a doublevertexSupplier - the vertex supplieredgeSupplier - the edge supplierpublic BaseValueGraphAdapter(VG valueGraph, java.util.function.ToDoubleFunction<W> valueConverter, java.util.function.Supplier<V> vertexSupplier, java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier, ElementOrderMethod<V> vertexOrderMethod)
valueGraph - the mutable value graphvalueConverter - a function that converts a value to a doublevertexSupplier - 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 java.util.function.Supplier<V> getVertexSupplier()
getVertexSupplier in interface Graph<V,com.google.common.graph.EndpointPair<V>>public void setVertexSupplier(java.util.function.Supplier<V> vertexSupplier)
A graph uses the vertex supplier to create new vertex objects whenever a user calls method
Graph.addVertex(). Users can also create the vertex in user code and then use method
Graph.addVertex(Object) to add the vertex.
In contrast with the Supplier interface, the vertex supplier has the additional
requirement that a new and distinct result is returned every time it is invoked. More
specifically for a new vertex to be added in a graph v must not be equal
to any other vertex in the graph. More formally, the graph must not contain any vertex
v2 such that v2.equals(v).
vertexSupplier - the vertex supplierpublic java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> getEdgeSupplier()
getEdgeSupplier in interface Graph<V,com.google.common.graph.EndpointPair<V>>public void setEdgeSupplier(java.util.function.Supplier<com.google.common.graph.EndpointPair<V>> edgeSupplier)
A graph uses the edge supplier to create new edge objects whenever a user calls method
Graph.addEdge(Object, Object). Users can also create the edge in user code and then
use method Graph.addEdge(Object, Object, Object) to add the edge.
In contrast with the Supplier interface, the edge supplier has the additional
requirement that a new and distinct result is returned every time it is invoked. More
specifically for a new edge to be added in a graph e must not be equal to
any other edge in the graph (even if the graph allows edge-multiplicity). More formally, the
graph must not contain any edge e2 such that e2.equals(e).
edgeSupplier - the edge supplierpublic java.util.Set<V> vertexSet()
public V getEdgeSource(com.google.common.graph.EndpointPair<V> e)
getEdgeSource in interface Graph<V,com.google.common.graph.EndpointPair<V>>public V getEdgeTarget(com.google.common.graph.EndpointPair<V> e)
getEdgeTarget in interface Graph<V,com.google.common.graph.EndpointPair<V>>public GraphType getType()
public boolean containsEdge(com.google.common.graph.EndpointPair<V> e)
containsEdge in interface Graph<V,com.google.common.graph.EndpointPair<V>>public boolean containsVertex(V v)
containsVertex in interface Graph<V,com.google.common.graph.EndpointPair<V>>public java.util.Set<com.google.common.graph.EndpointPair<V>> edgeSet()
public int degreeOf(V vertex)
public int inDegreeOf(V vertex)
inDegreeOf in interface Graph<V,com.google.common.graph.EndpointPair<V>>public java.util.Set<com.google.common.graph.EndpointPair<V>> incomingEdgesOf(V vertex)
incomingEdgesOf in interface Graph<V,com.google.common.graph.EndpointPair<V>>public int outDegreeOf(V vertex)
outDegreeOf in interface Graph<V,com.google.common.graph.EndpointPair<V>>public java.util.Set<com.google.common.graph.EndpointPair<V>> outgoingEdgesOf(V vertex)
outgoingEdgesOf in interface Graph<V,com.google.common.graph.EndpointPair<V>>public double getEdgeWeight(com.google.common.graph.EndpointPair<V> e)
getEdgeWeight in interface Graph<V,com.google.common.graph.EndpointPair<V>>public java.util.Set<com.google.common.graph.EndpointPair<V>> getAllEdges(V sourceVertex, V targetVertex)
getAllEdges in interface Graph<V,com.google.common.graph.EndpointPair<V>>protected org.jgrapht.graph.guava.ElementOrder<V> createVertexOrder(ElementOrderMethod<V> vertexOrderMethod)
vertexOrderMethod - method to useCopyright © 2021. All rights reserved.