@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);
    }
@Test
    public void removeEdge() {
        MutablePath<TestVertex, TestEdge> p = new DefaultMutablePath<>();
        p.appendEdge(new TestEdge(A, B));
        p.appendEdge(new TestEdge(B, C));
        p.appendEdge(new TestEdge(C, C));
        p.appendEdge(new TestEdge(C, D));
        validatePath(p, A, D, 4);

        p.removeEdge(new TestEdge(A, B));
        validatePath(p, B, D, 3);

        p.removeEdge(new TestEdge(C, C));
        validatePath(p, B, D, 2);

        p.removeEdge(new TestEdge(C, D));
        validatePath(p, B, C, 1);
    }