graph.addNode(node2);
graph.addNode(node3);
//Test normal edge
graph.addEdge(node1, node2);
AbstractNode preNode1 = (AbstractNode) node1;
AbstractNode preNode2 = (AbstractNode) node2;
AbstractEdge edge = preNode1.getEdgesOutTree().getItem(preNode2.getNumber());
assertNotNull("find OUT edge", edge);
assertTrue("contains OUT edge", preNode1.getEdgesOutTree().contains(edge));
AbstractEdge edge2 = preNode2.getEdgesInTree().getItem(preNode1.getNumber());
assertNotNull("find IN edge", edge);
assertTrue("contains IN edge", preNode2.getEdgesInTree().contains(edge2));
assertSame("edges equal", edge, edge2);
assertEquals("edges count", 1, graph.getEdgeCount());
//Test mutual edge add fail
graph.addEdge(node2, node1);
assertNull("cant find OUT edge", preNode2.getEdgesOutTree().getItem(preNode1.getNumber()));
assertEquals("edges count", 1, graph.getEdgeCount());
//Test factoryedge
graph.addEdge(edge);
assertEquals("edges count", 1, graph.getEdgeCount());
//Test self loop
graph.addEdge(node3, node3);
AbstractNode preNode3 = (AbstractNode) node3;
AbstractEdge edge3 = preNode3.getEdgesOutTree().getItem(preNode3.getNumber());
assertNotNull("find OUT edge", edge);
assertTrue("contains OUT edge", preNode3.getEdgesOutTree().contains(edge3));
AbstractEdge edge4 = preNode3.getEdgesInTree().getItem(preNode3.getNumber());
assertNotNull("find IN edge", edge);
assertTrue("contains IN edge", preNode3.getEdgesInTree().contains(edge3));
assertSame("edges equal", edge3, edge4);
assertTrue("is self loop", edge3.isSelfLoop());
}