Class GuavaNetworkAdapter<V,E>
- java.lang.Object
-
- com.google.common.graph.AbstractNetwork<V,E>
-
- com.jgalgo.adapt.guava.GuavaNetworkAdapter<V,E>
-
- Type Parameters:
V
- the vertices typeE
- the edges type
- All Implemented Interfaces:
Network<V,E>
,PredecessorsFunction<V>
,SuccessorsFunction<V>
- Direct Known Subclasses:
GuavaMutableNetworkAdapter
public class GuavaNetworkAdapter<V,E> extends AbstractNetwork<V,E>
An adapter from a JGAlgo graph to a Guava network.The adapter is constructed with a JGAlgo graph and implements the Guava network interface, and can be used with any Guava algorithm. The adapter is a live view, so any change in the JGAlgo graph is reflected in the Guava network and vice versa, but the underlying JGAlgo graph should not be modified directly.
The Guava network is immutable, so as this adapter. A subclass of this adapter,
GuavaMutableNetworkAdapter
, is a mutable adapter that implements the Guava mutable network interface.The capabilities of the Guava network, such as parallel and self edges or whether the network is directed or undirected, are determined by the underlying JGAlgo graph.
Guava support different element orders for the nodes and the incident edges. This adapter uses the default element order, which is unordered, and cannot be changed as the underlying JGAlgo graph does not support any other order.
Among Guava
Graph
,ValueGraph
andNetwork
, the network is the most similar to JGAlgo graphs, as vertices and edges have unique identifiers, and queries of edges are answered with the edges identifiers. On the other had, the Graph and ValueGraph do not support unique identifiers for the edges, and operations on edges are addressed by a pair of nodes. The ValueGraph does associate a value with each edge, be it does not have to be unique, and it is more similar to weights in JGAlgo graphs.For adapting the other way around, from Guava Network to JGAlgo, see
GuavaNetworkWrapper
.- Author:
- Barak Ugav
- See Also:
Graph
,Network
,GuavaMutableNetworkAdapter
,GuavaNetworkWrapper
-
-
Constructor Summary
Constructors Constructor Description GuavaNetworkAdapter(Graph<V,E> graph)
Constructs a new adapter from the given JGAlgo graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<E>
adjacentEdges(E edge)
Set<V>
adjacentNodes(V node)
boolean
allowsParallelEdges()
boolean
allowsSelfLoops()
E
edgeConnectingOrNull(V nodeU, V nodeV)
ElementOrder<E>
edgeOrder()
Set<E>
edges()
Set<E>
edgesConnecting(V nodeU, V nodeV)
boolean
hasEdgeConnecting(EndpointPair<V> endpoints)
boolean
hasEdgeConnecting(V nodeU, V nodeV)
Set<E>
incidentEdges(V node)
EndpointPair<V>
incidentNodes(E edge)
Set<E>
inEdges(V node)
boolean
isDirected()
ElementOrder<V>
nodeOrder()
Set<V>
nodes()
Set<E>
outEdges(V node)
Set<V>
predecessors(V node)
Set<V>
successors(V node)
-
Methods inherited from class com.google.common.graph.AbstractNetwork
asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgesConnecting, equals, hashCode, inDegree, outDegree, toString
-
-
-
-
Method Detail
-
incidentNodes
public EndpointPair<V> incidentNodes(E edge)
-
adjacentEdges
public Set<E> adjacentEdges(E edge)
- Specified by:
adjacentEdges
in interfaceNetwork<V,E>
- Overrides:
adjacentEdges
in classAbstractNetwork<V,E>
-
edgesConnecting
public Set<E> edgesConnecting(V nodeU, V nodeV)
- Specified by:
edgesConnecting
in interfaceNetwork<V,E>
- Overrides:
edgesConnecting
in classAbstractNetwork<V,E>
-
edgeConnectingOrNull
public E edgeConnectingOrNull(V nodeU, V nodeV)
- Specified by:
edgeConnectingOrNull
in interfaceNetwork<V,E>
- Overrides:
edgeConnectingOrNull
in classAbstractNetwork<V,E>
-
hasEdgeConnecting
public boolean hasEdgeConnecting(V nodeU, V nodeV)
- Specified by:
hasEdgeConnecting
in interfaceNetwork<V,E>
- Overrides:
hasEdgeConnecting
in classAbstractNetwork<V,E>
-
hasEdgeConnecting
public boolean hasEdgeConnecting(EndpointPair<V> endpoints)
- Specified by:
hasEdgeConnecting
in interfaceNetwork<V,E>
- Overrides:
hasEdgeConnecting
in classAbstractNetwork<V,E>
-
isDirected
public boolean isDirected()
-
allowsParallelEdges
public boolean allowsParallelEdges()
-
allowsSelfLoops
public boolean allowsSelfLoops()
-
nodeOrder
public ElementOrder<V> nodeOrder()
-
edgeOrder
public ElementOrder<E> edgeOrder()
-
-