//ensure correct graph structure
assertTrue(built.getEdges().size() == n);
assertTrue(built.getNodes().size() == n+1);
GraphVisitor visitor = new GraphVisitor() {
public int visit(Graphable component) {
Node node = (Node)component;
Coordinate c = (Coordinate)node.getObject();
if (node.getDegree() == 1) {
assertTrue(node.getID() == 0 || node.getID() == n);
}
else {
assertTrue(node.getDegree() == 2);
}
assertTrue(
c.x == base.x + node.getID() && c.y == base.y + node.getID()
);
return(0);
}
};
built.visitNodes(visitor);
visitor = new GraphVisitor() {
public int visit(Graphable component) {
Edge edge = (Edge)component;
LineSegment line = (LineSegment)edge.getObject();
assertTrue(line.p1.x == line.p0.x + 1 && line.p1.y == line.p0.y+1);