/** * @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object) */ public V getDest(E directed_edge) { return delegate.getDest(directed_edge); }
/** * @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object) */ @Override public V getDest(E directed_edge) { return delegate.getDest(directed_edge); }
/** * @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object) */ @Override public synchronized V getDest(E directed_edge) { return delegate.getDest(directed_edge); }
/** * @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object) */ @Override public V getDest(E directed_edge) { return delegate.getDest(directed_edge); }
/** * @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object) */ public V getDest(E directed_edge) { return delegate.getDest(directed_edge); }
/** * @see edu.uci.ics.jung.graph.Graph#getDest(java.lang.Object) */ public synchronized V getDest(E directed_edge) { return delegate.getDest(directed_edge); }
/** * Returns the destination of a directed edge. * @param directed_edge The edge. * @return The vertex. */ public Object getDest(Object directed_edge) { return delegate.getDest(directed_edge); }
public V getDest(E directedEdge) { return graph.getDest(directedEdge); } public int getEdgeCount() {
private boolean isDestination(final V target, final List<E> resultPath) { return graph.getDest(resultPath.get(resultPath.size() - 1)).equals(target); }
private static <V, E> void validatePath(Graph<V, E> graph, V source, V target, List<E> path) { if (!graph.isSource(source, path.get(0))) throw new RuntimeException("Bad - Source node is not the first node in the path"); Iterator<E> it = path.iterator(); E originVertex = it.next(); while (it.hasNext()) { E destinationVertex = it.next(); if (!graph.isSource(graph.getDest(originVertex), destinationVertex)) throw new RuntimeException("Bad - Path is not contiguous"); originVertex = destinationVertex; } if (!graph.isDest(target, path.get(path.size() - 1))) throw new RuntimeException("Bad - "); }
private List<E> restorePaths(final List<E> path, final V target, final List<E> partialMergedPaths) { final List<E> resultPath = new ArrayList<>(); resultPath.add(path.get(0)); partialMergedPaths.remove(path.get(0)); if (!isDestination(target, resultPath)){ V currentDestination = graph.getDest(resultPath.get(resultPath.size() - 1)); for (E edge : partialMergedPaths){ if (graph.isSource(currentDestination, edge)) { resultPath.add(edge); partialMergedPaths.remove(edge); break; } } } return resultPath; }
private void tarjan(final V v, final Graph<V, E> g) { this.indexmap.put(v, this.index); this.lowlinkmap.put(v, this.index); this.index++; this.stack.add(0, v); for (final E e : g.getOutEdges(v)) { final V n = g.getDest(e); if (this.indexmap.get(n) == null) { tarjan(n, g); this.lowlinkmap.put(v, Math.min(this.lowlinkmap.get(v), this.lowlinkmap.get(n))); } else if (this.stack.contains(n)) { this.lowlinkmap.put(v, Math.min(this.lowlinkmap.get(v), this.indexmap.get(n))); } } if (this.lowlinkmap.get(v).equals(this.indexmap.get(v))) { final Set<V> component = new HashSet<V>(); V n; do { n = this.stack.remove(0); component.add(n); } while (n != v); this.scc.add(component); } }
private void tarjan(final V v, final Graph<V, E> g) { this.indexmap.put(v, this.index); this.lowlinkmap.put(v, this.index); this.index++; this.stack.add(0, v); for (final E e : g.getOutEdges(v)) { final V n = g.getDest(e); if (this.indexmap.get(n) == null) { tarjan(n, g); this.lowlinkmap.put(v, Math.min(this.lowlinkmap.get(v), this.lowlinkmap.get(n))); } else if (this.stack.contains(n)) { this.lowlinkmap.put(v, Math.min(this.lowlinkmap.get(v), this.indexmap.get(n))); } } if (this.lowlinkmap.get(v).equals(this.indexmap.get(v))) { final Set<V> component = new HashSet<V>(); V n; do { n = this.stack.remove(0); component.add(n); } while (n != v); this.scc.add(component); } }
private List<E> recombinePaths(List<E> path, V target, List<E> union) { LinkedList<E> p = new LinkedList<E>(); /* provides getLast */ p.add(path.get(0)); union.remove(path.get(0)); V curDest; while (!(curDest = graph.getDest(p.getLast())).equals(target)) { boolean progress = false; for (E e : union) { if (graph.isSource(curDest, e)) { p.add(e); progress = true; union.remove(e); break; } } if (!progress) return null; if (union.isEmpty()) { if (!graph.isDest(target, p.getLast())) throw new RuntimeException("Bad"); else break; } } return p; }
private void discardCommonReversedEdges(final Graph<V,E> graph, final List<E> path1, final List<E> path2) { if (path1.size() == 0 || path2.size() == 0){ return; } else { final V source = graph.getSource(path1.get(0)); final V target = graph.getDest(path1.get(path1.size() - 1)); for(final E edge2 : path2){ for(final E edge1 : path1){ if (edge1.equals(edge2)){ if (graph.isSource(source, edge1) || graph.isSource(source, edge2) || graph.isDest(target, edge1) || graph.isDest(target, edge2)){ // Return only shortest path path2.clear(); return; } path1.remove(edge1); path2.remove(edge2); break; } } } } }
protected List<E> reverseUpdateEdgesWeight(final Graph<V, E> graph, final Transformer<V, Number> transformer, final List<E> shortestPath, final V initial, final V destination) { for(final E edge1 : shortestPath){ V src = graph.getSource(edge1); V dst = graph.getDest(edge1); graph.removeEdge(edge1); graph.addEdge(edge1, dst, src, EdgeType.DIRECTED); } final List<E> edges = new ArrayList<>(graph.getEdges()); final Map<E, Number> map = new LinkedHashMap<>(); edges.forEach(edge -> { final V source = graph.getSource(edge); final V dest = graph.getDest(edge); Number cost = calculateCost(transformer, edge, source, dest); map.put(edge,cost); }); final DijkstraShortestPath<V, E> reversedDijkstra = new DijkstraShortestPath<>(graph, MapTransformer.getInstance(map)); DijkstraShortestPath<V, E> validatedShortestPath = checkPath(initial, destination, reversedDijkstra); return validatedShortestPath != null ? reversedDijkstra.getPath(initial, destination) : new ArrayList<>(); }
/** Find and remove simple loops (e.g. a -> b -> a) from a Jung graph */ public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }
/** Find and remove simple loops (e.g. a -> b -> a) from a Jung graph */ public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }
Point2D dest = viewer.getGraphLayout().transform(graph.getDest(edge)); xmlw.writeStartElement("y:Point"); xmlw.writeAttribute("x", String.valueOf(source.getX()));
/** This method reverse the path "path" in the graph "graph" and returns it. * * @param graph the input graph which will not be changed. * @param path the path to reverse * @return a new graph with the reversed path * @since 0.3.0 */ private static <V, E> Graph<V, E> reverseEdges(Graph<V, E> graph, List<E> path) { if (graph == null || path == null) throw new IllegalArgumentException(); Graph<V, E> clone = new DirectedOrderedSparseMultigraph<V, E>(); for (V v : graph.getVertices()) clone.addVertex(v); for (E e : graph.getEdges()) clone.addEdge(e, graph.getEndpoints(e)); for (E link : path) { V src = clone.getSource(link); V dst = clone.getDest(link); clone.removeEdge(link); clone.addEdge(link, dst, src, EdgeType.DIRECTED); } return clone; }