Class BaseNetworkAdapter<V,E,N extends com.google.common.graph.Network<V,E>>
- java.lang.Object
-
- org.jgrapht.graph.AbstractGraph<V,E>
-
- org.jgrapht.graph.guava.BaseNetworkAdapter<V,E,N>
-
- Type Parameters:
V- the graph vertex typeE- the graph edge typeN- type of the underlying Guava's network
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,org.jgrapht.Graph<V,E>
- Direct Known Subclasses:
ImmutableNetworkAdapter,MutableNetworkAdapter
public abstract class BaseNetworkAdapter<V,E,N extends com.google.common.graph.Network<V,E>> extends org.jgrapht.graph.AbstractGraph<V,E> implements org.jgrapht.Graph<V,E>, java.lang.Cloneable, java.io.SerializableA base abstract implementation for the graph adapter class using Guava'sNetwork. This is a helper class in order to support both mutable and immutable networks.- Author:
- Dimitrios Michail
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.Supplier<E>edgeSupplierprotected static java.lang.StringLOOPS_NOT_ALLOWEDprotected Nnetworkprotected java.util.Set<E>unmodifiableEdgeSetprotected java.util.Set<V>unmodifiableVertexSetprotected java.util.function.Supplier<V>vertexSupplier
-
Constructor Summary
Constructors Constructor Description BaseNetworkAdapter(N network)Create a new network adapter.BaseNetworkAdapter(N network, java.util.function.Supplier<V> vertexSupplier, java.util.function.Supplier<E> edgeSupplier)Create a new network adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsEdge(E e)booleancontainsVertex(V v)intdegreeOf(V vertex)java.util.Set<E>edgeSet()java.util.Set<E>edgesOf(V vertex)java.util.Set<E>getAllEdges(V sourceVertex, V targetVertex)EgetEdge(V sourceVertex, V targetVertex)VgetEdgeSource(E e)java.util.function.Supplier<E>getEdgeSupplier()VgetEdgeTarget(E e)doublegetEdgeWeight(E e)org.jgrapht.GraphTypegetType()java.util.function.Supplier<V>getVertexSupplier()java.util.Set<E>incomingEdgesOf(V vertex)intinDegreeOf(V vertex)intoutDegreeOf(V vertex)java.util.Set<E>outgoingEdgesOf(V vertex)voidsetEdgeSupplier(java.util.function.Supplier<E> edgeSupplier)Set the edge supplier that the graph uses whenever it needs to create new edges.voidsetVertexSupplier(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()-
Methods inherited from class org.jgrapht.graph.AbstractGraph
assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSets
-
-
-
-
Field Detail
-
LOOPS_NOT_ALLOWED
protected static final java.lang.String LOOPS_NOT_ALLOWED
- See Also:
- Constant Field Values
-
unmodifiableVertexSet
protected transient java.util.Set<V> unmodifiableVertexSet
-
unmodifiableEdgeSet
protected transient java.util.Set<E> unmodifiableEdgeSet
-
vertexSupplier
protected java.util.function.Supplier<V> vertexSupplier
-
edgeSupplier
protected java.util.function.Supplier<E> edgeSupplier
-
-
Constructor Detail
-
BaseNetworkAdapter
public BaseNetworkAdapter(N network)
Create a new network adapter.- Parameters:
network- the mutable network
-
-
Method Detail
-
getVertexSupplier
public java.util.function.Supplier<V> getVertexSupplier()
-
setVertexSupplier
public void setVertexSupplier(java.util.function.Supplier<V> vertexSupplier)
Set the vertex supplier that the graph uses whenever it needs to create new vertices.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 methodGraph.addVertex(Object)to add the vertex.In contrast with the
Supplierinterface, 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 graphvmust not be equal to any other vertex in the graph. More formally, the graph must not contain any vertexv2such thatv2.equals(v).- Parameters:
vertexSupplier- the vertex supplier
-
getEdgeSupplier
public java.util.function.Supplier<E> getEdgeSupplier()
-
setEdgeSupplier
public void setEdgeSupplier(java.util.function.Supplier<E> edgeSupplier)
Set the edge supplier that the graph uses whenever it needs to create new edges.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 methodGraph.addEdge(Object, Object, Object)to add the edge.In contrast with the
Supplierinterface, 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 graphemust 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 edgee2such thate2.equals(e).- Parameters:
edgeSupplier- the edge supplier
-
vertexSet
public java.util.Set<V> vertexSet()
-
getType
public org.jgrapht.GraphType getType()
-
containsEdge
public boolean containsEdge(E e)
-
containsVertex
public boolean containsVertex(V v)
-
edgeSet
public java.util.Set<E> edgeSet()
-
inDegreeOf
public int inDegreeOf(V vertex)
-
outDegreeOf
public int outDegreeOf(V vertex)
-
getEdgeWeight
public double getEdgeWeight(E e)
-
-