package classycle.graph;

import junit.framework.TestCase;

/**
 * 
 * 
 * @author Franz-Josef Elmer
 */
public class VertexTest extends TestCase {
	public VertexTest(String name) {
		super(name);
	}

  public void testAddOutgoingArc() {
    Vertex tail = new Vertex(null);
    Vertex head = new Vertex(null);

    tail.addOutgoingArcTo(head);
    assertEquals(0, tail.getNumberOfIncomingArcs());
    assertEquals(1, tail.getNumberOfOutgoingArcs());
    assertSame(head, tail.getHeadVertex(0));
    assertEquals(0, head.getNumberOfOutgoingArcs());
    assertEquals(1, head.getNumberOfIncomingArcs());
    assertSame(tail, head.getTailVertex(0));

    tail.addOutgoingArcTo(head);
    assertEquals(1, tail.getNumberOfOutgoingArcs());
  }
}

@@ -57,53 +57,8 @@
 e;%0A%0A
-/**%0A * %0A * %0A * @author Franz-Josef Elmer%0A */%0A
 publ
@@ -591,24 +591,62 @@
 ertex(0));%0A%0A
+    // multiple arcs are not possible%0A
     tail.add
@@ -719,14 +719,1515 @@
 rcs());%0A
+    %0A    // add second arc%0A    Vertex head2 = new Vertex(null);%0A    tail.addOutgoingArcTo(head2);%0A    assertEquals(0, tail.getNumberOfIncomingArcs());%0A    assertEquals(2, tail.getNumberOfOutgoingArcs());%0A    assertSame(head, tail.getHeadVertex(0));%0A    assertSame(head2, tail.getHeadVertex(1));%0A  %7D%0A%0A  public void testAddIncomingArc() %7B%0A    Vertex head = new Vertex(null);%0A    Vertex tail = new Vertex(null);%0A%0A    head.addIncomingArcTo(tail);%0A    assertEquals(0, head.getNumberOfOutgoingArcs());%0A    assertEquals(1, head.getNumberOfIncomingArcs());%0A    assertSame(tail, head.getTailVertex(0));%0A    assertEquals(0, tail.getNumberOfIncomingArcs());%0A    assertEquals(1, tail.getNumberOfOutgoingArcs());%0A    assertSame(head, tail.getHeadVertex(0));%0A%0A    // multiple arcs are not possible%0A    head.addIncomingArcTo(tail);%0A    assertEquals(1, head.getNumberOfIncomingArcs());%0A    %0A    // add second arc%0A    Vertex tail2 = new Vertex(null);%0A    head.addIncomingArcTo(tail2);%0A    assertEquals(0, head.getNumberOfOutgoingArcs());%0A    assertEquals(2, head.getNumberOfIncomingArcs());%0A    assertSame(tail, head.getTailVertex(0));%0A    assertSame(tail2, head.getTailVertex(1));%0A  %7D%0A  %0A  public void testVisit() %7B%0A    Vertex vertex = new Vertex(null);%0A    assertTrue(!vertex.isVisited());%0A    vertex.visit();%0A    assertTrue(vertex.isVisited());%0A    vertex.visit();%0A    assertTrue(vertex.isVisited());%0A    vertex.reset();%0A    assertTrue(!vertex.isVisited());%0A    vertex.reset();%0A    assertTrue(!vertex.isVisited());%0A
   %7D%0A%7D%0A

add - more tests