@Test public void hasEdge() { 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)); assertFalse(graph.hasEdge(hello1Vertex, helloVertex)); Vertex<String> anotherVertex = graph.addVertex("another"); assertFalse(graph.hasEdge(helloVertex, anotherVertex)); assertFalse(graph.hasEdge(hello1Vertex, anotherVertex)); assertFalse(graph.hasEdge(anotherVertex, helloVertex)); assertFalse(graph.hasEdge(anotherVertex, hello1Vertex)); }
@Override public boolean hasEdge(Vertex<T> from, Vertex<T> to) { return (from != null) && (to != null) && vertices.containsKey(from.getValue()) && vertices.containsKey(to.getValue()) && from.hasEdgeTo(to); }
DirectedAcyclicGraph implements Graph<T> { @Override public boolean hasEdge(Vertex<T> from, Vertex<T> to) { return (from != null) && (to != null) && vertices.containsKey(from.getValue()) && vertices.containsKey(to.getValue()) && from.hasEdgeTo(to); } }
DirectedAcyclicGraph implements Graph<T> { @Override public boolean hasEdge(Vertex<T> from, Vertex<T> to) { return (from != null) && (to != null) && vertices.containsKey(from.getValue()) && vertices.containsKey(to.getValue()) && from.hasEdgeTo(to); } DirectedAcyclicGraph(); }
DirectedAcyclicGraph implements Graph<T> { @Override public boolean hasEdge(Vertex<T> from, Vertex<T> to) { return (from != null) && (to != null) && vertices.containsKey(from.getValue()) && vertices.containsKey(to.getValue()) && from.hasEdgeTo(to); } 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 boolean hasEdge(Vertex<T> from, Vertex<T> to) { return (from != null) && (to != null) && vertices.containsKey(from.getValue()) && vertices.containsKey(to.getValue()) && from.hasEdgeTo(to); } 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();  }