@Test
public void testConnectionIteratorAfterRemoval() {

	this.network.removeRoadSegment(this.segment4);
	this.network.removeRoadSegment(this.segment6);
	this.segment4 = this.segment6 = null;
	// CAUTION: Remember that segment4 and segment6 were removed!
	assumeTrue(CoordinateSystem2D.getDefaultCoordinateSystem().isRightHanded());
	Iterator<RoadSegment> iterator = this.segment1.getBeginPoint().toCounterclockwiseIterator(this.segment1);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment1, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment1.getEndPoint().toCounterclockwiseIterator(this.segment1);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment1, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment2, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment2.getBeginPoint().toCounterclockwiseIterator(this.segment2);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment2, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment5, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment3, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment7, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment8, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment9, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment2.getEndPoint().toCounterclockwiseIterator(this.segment2);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment2, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment1, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment3.getBeginPoint().toCounterclockwiseIterator(this.segment3);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment3, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment7, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment8, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment9, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment2, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment5, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment3.getEndPoint().toCounterclockwiseIterator(this.segment3);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment3, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment5.getBeginPoint().toCounterclockwiseIterator(this.segment5);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment5, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment3, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment7, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment8, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment9, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment2, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment5.getEndPoint().toCounterclockwiseIterator(this.segment5);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment5, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment7.getBeginPoint().toCounterclockwiseIterator(this.segment7);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment7, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment8, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment9, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment2, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment5, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment3, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment7.getEndPoint().toCounterclockwiseIterator(this.segment7);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment7, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment8.getBeginPoint().toCounterclockwiseIterator(this.segment8);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment8, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment8.getEndPoint().toCounterclockwiseIterator(this.segment8);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment8, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment9, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment2, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment5, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment3, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment7, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment9.getBeginPoint().toCounterclockwiseIterator(this.segment9);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment9, iterator.next());
	assertFalse(iterator.hasNext());
	iterator = this.segment9.getEndPoint().toCounterclockwiseIterator(this.segment9);
	assertTrue(iterator.hasNext());
	assertEquals(this.segment9, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment2, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment5, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment3, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment7, iterator.next());
	assertTrue(iterator.hasNext());
	assertEquals(this.segment8, iterator.next());
	assertFalse(iterator.hasNext());
}