LinkedList<E> path = new LinkedList<E>(); Map<N, E> incomingEdges = sp.getIncomingEdgeMap(source);
/** * Returns a <code>List</code> of the edges on the shortest path from * <code>source</code> to <code>target</code>, in order of their occurrence * on this path. */ public static <V, E> List<E> getPath(Graph<V, E> graph, ShortestPath<V, E> sp, V source, V target) { LinkedList<E> path = new LinkedList<E>(); Map<V, E> incomingEdges = sp.getIncomingEdgeMap(source); if (incomingEdges.isEmpty() || incomingEdges.get(target) == null) { return path; } V current = target; while (!current.equals(source)) { E incoming = incomingEdges.get(current); path.addFirst(incoming); Pair<V> endpoints = graph.getEndpoints(incoming); if (endpoints.getFirst().equals(current)) { current = endpoints.getSecond(); } else { current = endpoints.getFirst(); } // incoming.getOpposite(current); } return path; } }
/** * Returns a <code>List</code> of the edges on the shortest path from * <code>source</code> to <code>target</code>, in order of their * occurrence on this path. */ public static <V, E> List<E> getPath(Graph<V,E> graph, ShortestPath<V,E> sp, V source, V target) { LinkedList<E> path = new LinkedList<E>(); Map<V,E> incomingEdges = sp.getIncomingEdgeMap(source); if (incomingEdges.isEmpty() || incomingEdges.get(target) == null) return path; V current = target; while (!current.equals(source)) { E incoming = incomingEdges.get(current); path.addFirst(incoming); Pair<V> endpoints = graph.getEndpoints(incoming); if(endpoints.getFirst().equals(current)) { current = endpoints.getSecond(); } else { current = endpoints.getFirst(); } //incoming.getOpposite(current); } return path; } }
Map<V,E> incomingEdges = sp.getIncomingEdgeMap(source);