use of org.jgrapht.alg.DijkstraShortestPath in project alliance by codice.
the class DAGConverter method printDAG.
public static void printDAG(DAG dag) {
if (dag.nodes != null && dag.edges != null) {
Map<Integer, Node> nodeMap = ResultDAGConverter.createNodeMap(dag.nodes);
DirectedAcyclicGraph<Node, Edge> graph = getNodeEdgeDirectedAcyclicGraph(dag, nodeMap);
DepthFirstIterator<Node, Edge> depthFirstIterator = new DepthFirstIterator<>(graph);
Node rootNode = null;
while (depthFirstIterator.hasNext()) {
depthFirstIterator.setCrossComponentTraversal(false);
Node node = depthFirstIterator.next();
if (rootNode == null) {
rootNode = node;
}
DijkstraShortestPath<Node, Edge> path = new DijkstraShortestPath<>(graph, rootNode, node);
printNode(node, (int) Math.round(path.getPathLength()));
}
}
}
Aggregations