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
ConstructorsConstructorDescriptionJGraphTAdapter(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 TypeMethodDescriptionbooleanbooleanbooleancontainsEdge(E e) booleancontainsEdge(V sourceVertex, V targetVertex) booleancontainsVertex(V v) intedgeSet()getAllEdges(V sourceVertex, V targetVertex) getEdgeSource(E e) getEdgeTarget(E e) doublegetEdgeWeight(E e) getType()incomingEdgesOf(V vertex) intinDegreeOf(V vertex) intoutDegreeOf(V vertex) outgoingEdgesOf(V vertex) removeAllEdges(V sourceVertex, V targetVertex) booleanremoveEdge(E e) removeEdge(V sourceVertex, V targetVertex) booleanremoveVertex(V v) voidsetEdgeSupplier(Supplier<E> edgeSupplier) Set the edge supplier of the adapter.voidsetEdgeWeight(E e, double weight) voidsetVertexSupplier(Supplier<V> vertexSupplier) Set the vertex supplier of the adapter.Methods inherited from class org.jgrapht.graph.AbstractGraph
equals, hashCode, removeAllEdges, removeAllVertices, toStringMethods 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)), ornullfor unweighted- Throws:
IllegalArgumentException- if the edge weight key is notnulland it is not found in the JGAlgo graph
-
-
Method Details
-
setVertexSupplier
Set the vertex supplier of the adapter.- Parameters:
vertexSupplier- the vertex supplier, ornullto not support adding vertices viaaddVertex()
-
setEdgeSupplier
Set the edge supplier of the adapter.- Parameters:
edgeSupplier- the edge supplier, ornullto not support adding edges viaaddEdge(Object, Object)
-
getAllEdges
-
getEdge
-
getVertexSupplier
-
getEdgeSupplier
-
addEdge
-
addEdge
-
addVertex
-
addVertex
-
containsEdge
- Specified by:
containsEdgein interfaceGraph<V,E> - Overrides:
containsEdgein classAbstractGraph<V,E>
-
containsEdge
-
containsVertex
-
edgeSet
-
degreeOf
-
edgesOf
-
inDegreeOf
-
incomingEdgesOf
-
outDegreeOf
-
outgoingEdgesOf
-
removeAllEdges
- Specified by:
removeAllEdgesin interfaceGraph<V,E> - Overrides:
removeAllEdgesin classAbstractGraph<V,E>
-
removeEdge
-
removeEdge
-
removeVertex
-
vertexSet
-
getEdgeSource
-
getEdgeTarget
-
getType
-
getEdgeWeight
-
setEdgeWeight
-