Class JGraphTAdapter<V,E>
- Type Parameters:
V
- the vertices typeE
- the edges type
- All Implemented Interfaces:
Graph<V,
E>
The adapter is constructed with a JGAlgo graph and implements the JGraphT graph interface, and can be used with any JGraphT algorithm. The adapter is a live view, so any change in the JGraphT graph is reflected in the JGAlgo graph and vice versa, but the underlying JGAlgo graph should not be modified directly.
The GraphType
of the adapter determined by the capabilities of the underlying JGAlgo graph (see
Graph.isDirected()
, Graph.isAllowParallelEdges()
,
Graph.isAllowSelfEdges()
). Wether the adapter is weighted or not is determined in the
constructor by passing the edge weight key, see
Graph.edgesWeights(String)
. Although JGAlgo graphs support multiple types of weights, both
for vertices and edges, JGraphT graphs support only one double weight type, for edges.
For adapting the other way around, from JGraphT to JGAlgo, see JGraphTWrapper
.
- Author:
- Barak Ugav
- See Also:
-
Field Summary
Fields inherited from interface org.jgrapht.Graph
DEFAULT_EDGE_WEIGHT
-
Constructor Summary
ConstructorDescriptionJGraphTAdapter
(Graph<V, E> graph) Constructs a new unweighted adapter from the given JGAlgo graph.JGraphTAdapter
(Graph<V, E> graph, String edgeWeightKey) Constructs a new adapter from the given JGAlgo graph, optionally weighted. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
boolean
containsEdge
(E e) boolean
containsEdge
(V sourceVertex, V targetVertex) boolean
containsVertex
(V v) int
edgeSet()
getAllEdges
(V sourceVertex, V targetVertex) getEdgeSource
(E e) getEdgeTarget
(E e) double
getEdgeWeight
(E e) getType()
incomingEdgesOf
(V vertex) int
inDegreeOf
(V vertex) int
outDegreeOf
(V vertex) outgoingEdgesOf
(V vertex) removeAllEdges
(V sourceVertex, V targetVertex) boolean
removeEdge
(E e) removeEdge
(V sourceVertex, V targetVertex) boolean
removeVertex
(V v) void
setEdgeSupplier
(Supplier<E> edgeSupplier) Set the edge supplier of the adapter.void
setEdgeWeight
(E e, double weight) void
setVertexSupplier
(Supplier<V> vertexSupplier) Set the vertex supplier of the adapter.Methods inherited from class org.jgrapht.graph.AbstractGraph
equals, hashCode, removeAllEdges, removeAllVertices, toString
Methods inherited from interface org.jgrapht.Graph
iterables, setEdgeWeight
-
Constructor Details
-
JGraphTAdapter
Constructs a new unweighted adapter from the given JGAlgo graph.- Parameters:
graph
- the JGAlgo graph
-
JGraphTAdapter
Constructs a new adapter from the given JGAlgo graph, optionally weighted.- Parameters:
graph
- the JGAlgo graphedgeWeightKey
- the edge weight key of the double weights of the JGAlgo graph (seeGraph.edgesWeights(String)
), ornull
for unweighted- Throws:
IllegalArgumentException
- if the edge weight key is notnull
and it is not found in the JGAlgo graph
-
-
Method Details
-
setVertexSupplier
Set the vertex supplier of the adapter.- Parameters:
vertexSupplier
- the vertex supplier, ornull
to not support adding vertices viaaddVertex()
-
setEdgeSupplier
Set the edge supplier of the adapter.- Parameters:
edgeSupplier
- the edge supplier, ornull
to not support adding edges viaaddEdge(Object, Object)
-
getAllEdges
-
getEdge
-
getVertexSupplier
-
getEdgeSupplier
-
addEdge
-
addEdge
-
addVertex
-
addVertex
-
containsEdge
- Specified by:
containsEdge
in interfaceGraph<V,
E> - Overrides:
containsEdge
in classAbstractGraph<V,
E>
-
containsEdge
-
containsVertex
-
edgeSet
-
degreeOf
-
edgesOf
-
inDegreeOf
-
incomingEdgesOf
-
outDegreeOf
-
outgoingEdgesOf
-
removeAllEdges
- Specified by:
removeAllEdges
in interfaceGraph<V,
E> - Overrides:
removeAllEdges
in classAbstractGraph<V,
E>
-
removeEdge
-
removeEdge
-
removeVertex
-
vertexSet
-
getEdgeSource
-
getEdgeTarget
-
getType
-
getEdgeWeight
-
setEdgeWeight
-