@Test public void removeEdge() { MutablePath<TestVertex, TestEdge> p = new DefaultMutablePath<>(); p.appendEdge(new TestEdge(A, B, 1)); p.appendEdge(new TestEdge(B, C, 1)); p.appendEdge(new TestEdge(C, C, 2)); p.appendEdge(new TestEdge(C, D, 1)); validatePath(p, A, D, 4); p.removeEdge(new TestEdge(A, B, 1)); validatePath(p, B, D, 3); p.removeEdge(new TestEdge(C, C, 2)); validatePath(p, B, D, 2); p.removeEdge(new TestEdge(C, D, 1)); validatePath(p, B, C, 1); }
@Override public void removeEdge(E edge) { checkArgument(edge.src().equals(edge.dst()) || edges.indexOf(edge) == 0 || edges.lastIndexOf(edge) == edges.size() - 1, "Edge must be at start or end of path, or it must be a cyclic edge"); edges.remove(edge); }
DefaultMutablePath implements MutablePath<V, E> { @Override public void removeEdge(E edge) { checkArgument(edge.src().equals(edge.dst()) || edges.indexOf(edge) == 0 || edges.lastIndexOf(edge) == edges.size() - 1, "Edge must be at start or end of path, or it must be a cyclic edge"); edges.remove(edge); } }
DefaultMutablePath implements MutablePath<V, E> { @Override public void removeEdge(E edge) { checkArgument(edge.src().equals(edge.dst()) || edges.indexOf(edge) == 0 || edges.lastIndexOf(edge) == edges.size() - 1, "Edge must be at start or end of path, or it must be a cyclic edge"); edges.remove(edge); } DefaultMutablePath();  DefaultMutablePath(Path<V, E> path); }
DefaultMutablePath implements MutablePath<V, E> { @Override public void removeEdge(E edge) { checkArgument(edge.src().equals(edge.dst()) || edges.indexOf(edge) == 0 || edges.lastIndexOf(edge) == edges.size() - 1, "Edge must be at start or end of path, or it must be a cyclic edge"); edges.remove(edge); } DefaultMutablePath();  DefaultMutablePath(Path<V, E> path); @Override V src(); @Override V dst(); @Override double cost(); @Override List<E> edges(); @Override void setCost(double cost); @Override Path<V, E> toImmutable(); @Override void insertEdge(E edge); @Override void appendEdge(E edge); @Override void removeEdge(E edge); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
DefaultMutablePath implements MutablePath<V, E> { @Override public void removeEdge(E edge) { checkArgument(edge.src().equals(edge.dst()) || edges.indexOf(edge) == 0 || edges.lastIndexOf(edge) == edges.size() - 1, "Edge must be at start or end of path, or it must be a cyclic edge"); edges.remove(edge); } DefaultMutablePath();  DefaultMutablePath(Path<V, E> path); @Override V src(); @Override V dst(); @Override double cost(); @Override List<E> edges(); @Override void setCost(double cost); @Override Path<V, E> toImmutable(); @Override void insertEdge(E edge); @Override void appendEdge(E edge); @Override void removeEdge(E edge); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }