assertTrue(before.getEdges().size() == after.getEdges().size());
//ensure same structure
GraphVisitor visitor = new GraphVisitor() {
public int visit(Graphable component) {
DirectedNode n = (DirectedNode)component;
String id = (String)n.getObject();
assertTrue(obj2node.get(id) != null);
StringTokenizer st = new StringTokenizer(id, ".");
if (st.countTokens() == 1) {
//root
assertTrue(n.getDegree() == 2);
Node n0 = ((Edge)n.getEdges().get(0)).getOtherNode(n);
Node n1 = ((Edge)n.getEdges().get(1)).getOtherNode(n);
assertTrue(
n0.getObject().equals("0.0") && n1.getObject().equals("0.1")
|| n0.getObject().equals("0.1") && n1.getObject().equals("0.0")
);
}
else if (st.countTokens() == k+1) {
//leaf
assertTrue(n.getDegree() == 1);
Node parent = ((DirectedEdge)n.getInEdges().get(0)).getInNode();
String parentid = (String)parent.getObject();
assertTrue(parentid.equals(id.substring(0, id.length()-2)));
}
else {
//internal
assertTrue(n.getDegree() == 3);
String parent = ((DirectedEdge)n.getInEdges().get(0)).getInNode()
.getObject().toString();
String c0 = ((DirectedEdge)n.getOutEdges().get(0)).getOutNode()
.getObject().toString();
String c1 = ((DirectedEdge)n.getOutEdges().get(1)).getOutNode()
.getObject().toString();
String parentid = id.substring(0, id.length()-2);
assertTrue(