Class GuavaMutableNetworkAdapter<V,E>
- java.lang.Object
-
- com.google.common.graph.AbstractNetwork<V,E>
-
- com.jgalgo.adapt.guava.GuavaNetworkAdapter<V,E>
-
- com.jgalgo.adapt.guava.GuavaMutableNetworkAdapter<V,E>
-
- Type Parameters:
V
- the vertices typeE
- the edges type
- All Implemented Interfaces:
MutableNetwork<V,E>
,Network<V,E>
,PredecessorsFunction<V>
,SuccessorsFunction<V>
public class GuavaMutableNetworkAdapter<V,E> extends GuavaNetworkAdapter<V,E> implements MutableNetwork<V,E>
An adapter from a JGAlgo graph to a Guava network.The adapter is constructed with a JGAlgo graph and implements the mutable 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 mutable Guava network is a mutable variant of the Guava value graph. If mutability is not required, consider using the immutable adapter instead.
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
,MutableNetwork
,GuavaNetworkAdapter
,GuavaNetworkWrapper
-
-
Constructor Summary
Constructors Constructor Description GuavaMutableNetworkAdapter(Graph<V,E> graph)
Constructs a new mutable adapter from the given JGAlgo graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEdge(EndpointPair<V> endpoints, E edge)
boolean
addEdge(V nodeU, V nodeV, E edge)
boolean
addNode(V node)
boolean
removeEdge(E edge)
boolean
removeNode(V node)
-
Methods inherited from class com.jgalgo.adapt.guava.GuavaNetworkAdapter
adjacentEdges, adjacentNodes, allowsParallelEdges, allowsSelfLoops, edgeConnectingOrNull, edgeOrder, edges, edgesConnecting, hasEdgeConnecting, hasEdgeConnecting, incidentEdges, incidentNodes, inEdges, isDirected, nodeOrder, nodes, outEdges, predecessors, successors
-
Methods inherited from class com.google.common.graph.AbstractNetwork
asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgesConnecting, equals, hashCode, inDegree, outDegree, toString
-
Methods inherited from interface com.google.common.graph.Network
adjacentEdges, adjacentNodes, allowsParallelEdges, allowsSelfLoops, asGraph, degree, edgeConnecting, edgeConnecting, edgeConnectingOrNull, edgeConnectingOrNull, edgeOrder, edges, edgesConnecting, edgesConnecting, equals, hasEdgeConnecting, hasEdgeConnecting, hashCode, incidentEdges, incidentNodes, inDegree, inEdges, isDirected, nodeOrder, nodes, outDegree, outEdges, predecessors, successors
-
-
-
-
Method Detail
-
addNode
public boolean addNode(V node)
- Specified by:
addNode
in interfaceMutableNetwork<V,E>
-
addEdge
public boolean addEdge(V nodeU, V nodeV, E edge)
- Specified by:
addEdge
in interfaceMutableNetwork<V,E>
-
addEdge
public boolean addEdge(EndpointPair<V> endpoints, E edge)
- Specified by:
addEdge
in interfaceMutableNetwork<V,E>
-
removeNode
public boolean removeNode(V node)
- Specified by:
removeNode
in interfaceMutableNetwork<V,E>
-
removeEdge
public boolean removeEdge(E edge)
- Specified by:
removeEdge
in interfaceMutableNetwork<V,E>
-
-