Permalink
Browse files

Fixed removing of edges after deleting a vertex

  • Loading branch information...
1 parent 3d4456d commit 1db8341a54e9fcddd818cd47e3cd789d09394749 Prathamesh Sonpatki committed Sep 18, 2012
Showing with 10 additions and 0 deletions.
  1. +8 −0 spec/ir/directed_graph/directed_graph_spec.rb
  2. +2 −0 src/org/jruby/ir/util/Vertex.java
@@ -32,4 +32,12 @@
@graph.edges.size.should == 4
end
+ it "should remove a vertex and its associated edges" do
+ @graph.removeVertexFor(3)
+ @graph.edges.size.should == 2
+ @graph.vertices.size.should == 3
+ @graph.removeVertexFor(2)
+ @graph.vertices.size.should == 2
+ end
+
end
@@ -57,13 +57,15 @@ public boolean removeEdgeTo(Vertex destination) {
public void removeAllIncomingEdges() {
for (Edge edge: getIncomingEdges()) {
edge.getSource().getOutgoingEdges().remove(edge);
+ graph.edges().remove(edge);
}
incoming = null;
}
public void removeAllOutgoingEdges() {
for (Edge edge: getOutgoingEdges()) {
edge.getDestination().getIncomingEdges().remove(edge);
+ graph.edges().remove(edge);
}
outgoing = null;
}

0 comments on commit 1db8341

Please sign in to comment.