public static class GraphUtils.JGraphTUtils
extends Object
Auxiliary class to work with the graph library JGraphT.
Constructor and Description |
---|
GraphUtils.JGraphTUtils() |
Modifier and Type | Method and Description |
---|---|
static org.jgrapht.Graph<Long,Long> |
buildAuxiliaryNodeDisjointGraph(org.jgrapht.Graph<Long,Long> graph,
long originNode,
long destinationNode)
Builds an auxiliary graph for the application of edge-disjoint
shortest-path pair algorithms to node-disjoint problems.
|
static <V,E> org.jgrapht.WeightedGraph<V,E> |
getAsWeightedGraph(org.jgrapht.Graph<V,E> graph,
Map<E,Double> edgeWeightMap)
It generates a weighted view of the backing graph specified in the constructor.
|
static org.jgrapht.Graph<Long,Long> |
getGraphFromLinkMap(Map<Long,Pair<Long,Long>> linkMap)
Obtains a
JGraphT graph from a given link map. |
static org.jgrapht.Graph<Long,Long> |
getGraphFromLinkMap(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap)
Obtains a
JGraphT graph from a given link map. |
static boolean |
isBidirectional(org.jgrapht.Graph graph)
Check whether the topology has the same number of links between each node pair in both directions (assuming multi-digraphs).
|
static boolean |
isConnected(org.jgrapht.Graph graph)
Check whether the graph is connected, that is, if it is possible to connect every node to each other.
|
static boolean |
isConnected(org.jgrapht.Graph graph,
Set vertices)
Check whether the graph is connected, that is, if it is possible to connect every node to each other, but only in a subset of vertices (subgraph).
|
static boolean |
isSimple(org.jgrapht.Graph graph)
Check whether the graph is simple, that is, if it has at most one link between each node pair (one per direction under directed graphs, one under undirected graphs).
|
static boolean |
isWeightedBidirectional(org.jgrapht.Graph graph)
Checks whether the graph has the same number of links between each node pair in both directions (assuming multi-digraphs) and same individual weights per direction.
|
public static org.jgrapht.Graph<Long,Long> buildAuxiliaryNodeDisjointGraph(org.jgrapht.Graph<Long,Long> graph, long originNode, long destinationNode)
graph
- Graph representing the networkoriginNode
- Origin nodedestinationNode
- Destination nodepublic static <V,E> org.jgrapht.WeightedGraph<V,E> getAsWeightedGraph(org.jgrapht.Graph<V,E> graph, Map<E,Double> edgeWeightMap)
It generates a weighted view of the backing graph specified in the constructor. This graph allows modules to apply algorithms designed for weighted graphs to an unweighted graph by providing an explicit edge weight mapping.
Query operations on this graph "read through" to the backing graph. Vertex addition/removal and edge addition/removal are supported.
V
- Vertex typeE
- Edge typegraph
- The backing graph over which a weighted view is to be creatededgeWeightMap
- A mapping of edges to weights (null means all to one)public static org.jgrapht.Graph<Long,Long> getGraphFromLinkMap(Map<Long,Pair<Long,Long>> linkMap)
Obtains a JGraphT
graph from a given link map.
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. Origin/destination nodes will be added as neededJGraphT
graphpublic static org.jgrapht.Graph<Long,Long> getGraphFromLinkMap(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap)
Obtains a JGraphT
graph from a given link map.
nodeIds
- Set of node identifierslinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. Only links whose end-nodes are in nodeIds
will be added to the graphJGraphT
graphpublic static boolean isBidirectional(org.jgrapht.Graph graph)
graph
- The graph to analyzetrue
if the graph is bidirectional, and false otherwisepublic static boolean isConnected(org.jgrapht.Graph graph)
graph
- The graph to analyzetrue
if the graph is connected, and false otherwisepublic static boolean isConnected(org.jgrapht.Graph graph, Set vertices)
graph
- The graph to analyzevertices
- Subset of verticestrue
if the subgraph is connected, and false otherwisepublic static boolean isSimple(org.jgrapht.Graph graph)
graph
- The graph to analyzetrue
if the graph is simple, and false otherwisepublic static boolean isWeightedBidirectional(org.jgrapht.Graph graph)
graph
- The graph to analyzetrue
if the graph is weighted-bidirectional, and false otherwise. By convention returns false
if network is empty