/** * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object) */ @Override public synchronized boolean removeEdge(E edge) { return delegate.removeEdge(edge); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object) */ @Override public boolean removeEdge(E edge) { return delegate.removeEdge(edge); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object) */ public boolean removeEdge(E edge) { return delegate.removeEdge(edge); }
/** * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object) */ public synchronized boolean removeEdge(E edge) { return delegate.removeEdge(edge); }
public boolean removeEdge(E edge) { return graph.removeEdge(edge); } public boolean removeVertex(V vertex) {
/** * Removes an edge. * @param edge The edge to remove. * @return <code>true</code> if success. */ public boolean removeEdge(Object edge) { internal_removeEdge(edge); return delegate.removeEdge(edge); }
public void actionPerformed(ActionEvent e) { pickedEdgeState.pick(edge, false); graph.removeEdge(edge); vv.repaint(); }}); } else {
/** * @see edu.uci.ics.jung.graph.Hypergraph#removeEdge(java.lang.Object) */ @Override public boolean removeEdge(E edge) { boolean state = delegate.removeEdge(edge); if(state) { GraphEvent<V,E> evt = new GraphEvent.Edge<V,E>(delegate, GraphEvent.Type.EDGE_REMOVED, edge); fireGraphEvent(evt); } return state; }
/** * Generates a graph whose degree distribution approximates a power-law. * @return the generated graph */ public Graph<V,E> get() { Graph<V,E> graph = initializeGraph(); List<V> vertices = new ArrayList<V>(graph.getVertices()); for (int rIdx = 0; rIdx < mNumIterations; rIdx++) { V v = null; int degree = 0; do { v = vertices.get((int) (mRandom.nextDouble() * mNumVertices)); degree = graph.degree(v); } while (degree == 0); List<E> edges = new ArrayList<E>(graph.getIncidentEdges(v)); E randomExistingEdge = edges.get((int) (mRandom.nextDouble()*degree)); // FIXME: look at email thread on a more efficient RNG for arbitrary distributions V x = vertices.get((int) (mRandom.nextDouble() * mNumVertices)); V y = null; do { y = vertices.get((int) (mRandom.nextDouble() * mNumVertices)); } while (mRandom.nextDouble() > ((graph.degree(y)+1)/mMaxDegree)); if (!graph.isSuccessor(y,x) && x != y) { graph.removeEdge(randomExistingEdge); graph.addEdge(edgeFactory.get(), x, y); } } return graph; }
public ArrayList<Vertex> drawFromDeploymentModel() { Collection<Edge> c = new ArrayList<Edge>(graph.getEdges()); for (Edge e : c) { graph.removeEdge(e); } Collection<Vertex> vs = new ArrayList<Vertex>(graph.getVertices()); for (Vertex ve : vs) { graph.removeVertex(ve); } ArrayList<Vertex> v = drawVerticesFromDeploymentModel(dmodel); drawEdgesFromDeploymentModel(dmodel, v); System.out.println(vv); return v; }
graph.removeEdge(randomExistingEdge); graph.addEdge(edgeFactory.create(), x, y);
public void drawFromDeploymentModel(){ Collection<Edge> c = new ArrayList<Edge>(graph.getEdges()); for(Edge e : c) graph.removeEdge(e); Collection<Vertex> vs =new ArrayList<Vertex>(graph.getVertices()); for(Vertex ve : vs) graph.removeVertex(ve); ArrayList<Vertex> v = drawVerticesFromDeploymentModel(dmodel); drawEdgesFromDeploymentModel(dmodel, v); nodeTypes.removeAll(); nodeTypes.setModel(fillList()); }
/** * Generates a graph whose degree distribution approximates a power-law. * @return the generated graph */ public Graph<V,E> create() { Graph<V,E> graph = initializeGraph(); List<V> vertices = new ArrayList<V>(graph.getVertices()); for (int rIdx = 0; rIdx < mNumIterations; rIdx++) { V v = null; int degree = 0; do { v = vertices.get((int) (mRandom.nextDouble() * mNumVertices)); degree = graph.degree(v); } while (degree == 0); List<E> edges = new ArrayList<E>(graph.getIncidentEdges(v)); E randomExistingEdge = edges.get((int) (mRandom.nextDouble()*degree)); // FIXME: look at email thread on a more efficient RNG for arbitrary distributions V x = vertices.get((int) (mRandom.nextDouble() * mNumVertices)); V y = null; do { y = vertices.get((int) (mRandom.nextDouble() * mNumVertices)); } while (mRandom.nextDouble() > ((graph.degree(y)+1)/mMaxDegree)); if (!graph.isSuccessor(y,x) && x != y) { graph.removeEdge(randomExistingEdge); graph.addEdge(edgeFactory.create(), x, y); } } return graph; }
/** * Removes <code>edge</code> from this tree. * If <code>remove_subtree</code> is <code>true</code>, removes * the subtree rooted at the child vertex incident to <code>edge</code>. * Otherwise, leaves the subtree intact as a new component tree of this * forest. * @param edge the edge to remove * @param remove_subtree if <code>true</code>, remove the subtree * @return <code>true</code> iff the tree was modified */ public boolean removeEdge(E edge, boolean remove_subtree) { if (!delegate.containsEdge(edge)) return false; V child = getDest(edge); if (remove_subtree) return removeVertex(child); else { delegate.removeEdge(edge); return false; } }
/** * Removes <code>edge</code> from this tree. If <code>remove_subtree</code> * is <code>true</code>, removes the subtree rooted at the child vertex * incident to <code>edge</code>. Otherwise, leaves the subtree intact as a * new component tree of this forest. * * @param edge * the edge to remove * @param remove_subtree * if <code>true</code>, remove the subtree * @return <code>true</code> iff the tree was modified */ public boolean removeEdge(E edge, boolean remove_subtree) { if (!delegate.containsEdge(edge)) { return false; } V child = getDest(edge); if (remove_subtree) { return removeVertex(child); } delegate.removeEdge(edge); return false; }
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); } } } }
@Override public void rebuildGraph() { for (GUILink gl : new ArrayList<>(g.getEdges())) g.removeEdge(gl); for (GUINode gn : new ArrayList<>(g.getVertices())) g.removeVertex(gn); for (GUINode gn : callback.getVisualizationState().getCanvasAllGUINodes()) g.addVertex(gn); for (GUILink gl : callback.getVisualizationState().getCanvasAllGUILinks(true, true)) g.addEdge(gl, gl.getOriginNode(), gl.getDestinationNode()); updateAllVerticesXYPosition(); refresh(); }
/** 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; }