public boolean removeEdge(DirectedEdge<ExecutableMethod> e) { return graph.removeEdge(e); }
public DirectedEdge<ExecutableMethod> removeEdge(ExecutableMethod sourceVertex, ExecutableMethod targetVertex) { return graph.removeEdge(sourceVertex, targetVertex); }
public DirectedEdge<ExecutableMethod> removeEdge(ExecutableMethod sourceVertex, ExecutableMethod targetVertex) { return graph.removeEdge(sourceVertex, targetVertex); }
public boolean removeEdge(DirectedEdge<ExecutableMethod> e) { return graph.removeEdge(e); }
static public <V, E> void transitiveReduct(DirectedGraph<V, E> g) { final Set<V> cycles = new CycleDetector<V, E>(g).findCycles(); checkArgument(cycles.isEmpty(), cycles); // final Set<V> vertices = ImmutableSet.copyOf(g.vertexSet()); for (V v1 : g.vertexSet()) { for (V v2 : Sets.difference(g.vertexSet(), ImmutableSet.of(v1))) { for (V v3 : Sets.difference(g.vertexSet(), ImmutableSet.of(v1, v2))) { if (g.containsEdge(v1, v2) && g.containsEdge(v2, v3) && g.containsEdge(v1, v3)) { // final boolean hasRev1 = g.containsEdge(v2, v1); // final boolean hasRev2 = g.containsEdge(v3, v2); // final boolean hasRev3 = g.containsEdge(v3, v1); // if (hasRev1 != hasRev2 || hasRev1 != hasRev3) { // throw new IllegalArgumentException("Found cycle in " // + v1 + v2 + v3 + "."); // } // if (!hasRev1) { g.removeEdge(v1, v3); // } } } } } } }
/** * Redirects the edge target of the given edge to the given node by removing * the given edge from the graph and reinserting it from the original source * node to the given node * * @param edge a E object. * @param node a V object. * @return a boolean. */ protected boolean redirectEdgeTarget(E edge, V node) { if (!(containsVertex(node) && containsEdge(edge))) throw new IllegalArgumentException( "edge and node must be present in this graph"); V edgeSource = graph.getEdgeSource(edge); if (!graph.removeEdge(edge)) return false; if (!addEdge(edgeSource, node, edge)) return false; return true; }
/** * Redirects the edge source of the given edge to the given node by removing * the given edge from the graph and reinserting it from the given node to * the original target node * * @param edge a E object. * @param node a V object. * @return a boolean. */ protected boolean redirectEdgeSource(E edge, V node) { if (!(containsVertex(node) && containsEdge(edge))) throw new IllegalArgumentException( "edge and node must be present in this graph"); V edgeTarget = graph.getEdgeTarget(edge); if (!graph.removeEdge(edge)) return false; if (!addEdge(node, edgeTarget, edge)) return false; return true; }
@Override public void add(MethodGraph element, MethodGraph parent) { if (element.equals(parent)) { return; } directedGraph.addVertex(element); directedGraph.addVertex(parent); directedGraph.addEdge(parent, element); if (findCycles(element)) { directedGraph.removeEdge(parent, element); } }
for (Object e : new ArrayList<>(graphContext.graph.edgeSet())) { if (graphContext.edgeCount.get(e).get() != topoChoice.getPossibleTopologies().size()) { graphContext.graph.removeEdge(e); graphContext.edgeCount.remove(e);
graph.removeEdge(parent, discardedVertex); graph.addEdge(parent, preservedVertex); updateVertex(parent, parentRel);
regexGraph); if (det.detectCycles()) { regexGraph.removeEdge(currentState, t.getDest());
/** * Removes cycles from the graph that was used to construct the cycle handler. * @throws WikiApiException Thrown if errors occurred. */ public void removeCycles() throws WikiApiException { DefaultEdge edge = null; while ((edge = findCycle()) != null) { Category sourceCat = wiki.getCategory(categoryGraph.getGraph().getEdgeSource(edge)); Category targetCat = wiki.getCategory(categoryGraph.getGraph().getEdgeTarget(edge)); logger.info("Removing cycle: " + sourceCat.getTitle() + " - " + targetCat.getTitle()); categoryGraph.getGraph().removeEdge(edge); } }
@Test public void irreducibleTest() { DirectedGraph<String, DefaultEdge> directedGraph = new DefaultDirectedGraph<String, DefaultEdge>( DefaultEdge.class); directedGraph.addVertex("1");// src directedGraph.addVertex("2"); directedGraph.addVertex("3"); directedGraph.addVertex("4"); directedGraph.addVertex("5"); directedGraph.addVertex("6"); //sink directedGraph.addEdge("1", "2");//makes it irreducible directedGraph.addEdge("1", "3"); directedGraph.addEdge("2", "4"); directedGraph.addEdge("3", "4"); directedGraph.addEdge("4", "5"); directedGraph.addEdge("5", "2"); directedGraph.addEdge("3", "6"); Assert.assertFalse(GraphUtil.isReducibleGraph(directedGraph, "1")); directedGraph.removeEdge("1", "2"); Assert.assertTrue(GraphUtil.isReducibleGraph(directedGraph, "1")); }