@Test public void removeEdge() { DirectedAcyclicGraph<String> graph = new DirectedAcyclicGraph<String>(); Vertex<String> helloVertex = graph.addVertex("hello"); Vertex<String> hello1Vertex = graph.addVertex("hello1"); graph.addEdge(helloVertex, hello1Vertex); assertTrue(graph.hasEdge(helloVertex, hello1Vertex)); graph.removeEdge(hello1Vertex, helloVertex); assertTrue(graph.hasEdge(helloVertex, hello1Vertex)); graph.removeEdge(helloVertex, hello1Vertex); assertFalse(graph.hasEdge(helloVertex, hello1Vertex)); }
@Override public void removeEdge(Vertex<T> from, Vertex<T> to) { if ((from == null) || (to == null) || !vertices.containsKey(from.getValue()) || !vertices.containsKey(to.getValue())) { return; } from.removeEdgeTo(to); to.removeEdgeFrom(from); }
DirectedAcyclicGraph implements Graph<T> { @Override public void removeEdge(Vertex<T> from, Vertex<T> to) { if ((from == null) || (to == null) || !vertices.containsKey(from.getValue()) || !vertices.containsKey(to.getValue())) { return; } from.removeEdgeTo(to); to.removeEdgeFrom(from); } }
DirectedAcyclicGraph implements Graph<T> { @Override public void removeEdge(Vertex<T> from, Vertex<T> to) { if ((from == null) || (to == null) || !vertices.containsKey(from.getValue()) || !vertices.containsKey(to.getValue())) { return; } from.removeEdgeTo(to); to.removeEdgeFrom(from); } DirectedAcyclicGraph(); }
DirectedAcyclicGraph implements Graph<T> { @Override public void removeEdge(Vertex<T> from, Vertex<T> to) { if ((from == null) || (to == null) || !vertices.containsKey(from.getValue()) || !vertices.containsKey(to.getValue())) { return; } from.removeEdgeTo(to); to.removeEdgeFrom(from); } DirectedAcyclicGraph(); @Override Vertex<T> addVertex(T of); @Override void addEdge(Vertex<T> from, Vertex<T> to); @Override void removeEdge(Vertex<T> from, Vertex<T> to); @Override Vertex<T> getVertex(T of); @Override boolean hasVertex(T of); @Override boolean hasEdge(Vertex<T> from, Vertex<T> to); @Override boolean isCyclic(); @Override List<Vertex<T>> getVertices(); @Override List<Vertex<T>> getRootVertices(); @Override String toString(); }
DirectedAcyclicGraph implements Graph<T> { @Override public void removeEdge(Vertex<T> from, Vertex<T> to) { if ((from == null) || (to == null) || !vertices.containsKey(from.getValue()) || !vertices.containsKey(to.getValue())) { return; } from.removeEdgeTo(to); to.removeEdgeFrom(from); } DirectedAcyclicGraph(); @Override Vertex<T> addVertex(T of); @Override void addEdge(Vertex<T> from, Vertex<T> to); @Override void removeEdge(Vertex<T> from, Vertex<T> to); @Override Vertex<T> getVertex(T of); @Override boolean hasVertex(T of); @Override boolean hasEdge(Vertex<T> from, Vertex<T> to); @Override boolean isCyclic(); @Override List<Vertex<T>> getVertices(); @Override List<Vertex<T>> getRootVertices(); @Override String toString();  }