package signature;

import junit.framework.Assert;

import org.junit.Test;

import signature.simple.SimpleGraph;
import signature.simple.SimpleVertexSignature;

public class HeightTest {
    
    public SimpleGraph makeTorus(int width, int height) {
        SimpleGraph graph = new SimpleGraph();
        // make a grid of width * height
        for (int i = 0; i < width - 1; i++) {
            for (int j = 0; j < height; j++) {
                int x = (width * j) + i;
                int y = x + 1;
                graph.makeEdge(x, y);
                if (j < height - 1) {
                    int z = width * (j + 1) + i;
                    graph.makeEdge(x, z);
                }
            }
        }
        // finish off the last column
        for (int i = 0; i < height - 1; i++) {
            int x = ((i + 1) * width) - 1;
            int y = ((i + 2) * width) - 1;
            graph.makeEdge(x, y);
        }
        
        int size = width * height;
        
        // connect the top edge to the bottom
        for (int i = 0; i < width; i++) {
            graph.makeEdge(i, size - width + i);
        }
        
        // connect the left edge to the right
        for (int j = 0; j < height; j++) {
            int x = width * j;
            int y = (x + width) - 1;
            graph.makeEdge(x, y);
        }
        
        return graph;
    }
    
    @Test
    public void torusTest() {
        int width = 6;
        int height = 5;
        
        SimpleGraph torus = makeTorus(width, height);
        System.out.println(torus);
        int diameter = Math.min(width, height);
        for (int h = 1; h <= diameter; h++) {
            SimpleVertexSignature sig0 = 
                new SimpleVertexSignature(0, h, torus);
            String zeroCanonical = sig0.toCanonicalString();
            System.out.println(h + "\t" + zeroCanonical);
            for (int i = 1; i < torus.getVertexCount(); i++) {
                SimpleVertexSignature sig = 
                    new SimpleVertexSignature(i, h, torus);
                Assert.assertEquals(zeroCanonical, sig.toCanonicalString());
            }
        }
    }

}

@@ -1376,18 +1376,8 @@
    %0A
-    @Test%0A
     
@@ -1392,214 +1392,59 @@
 oid 
-torusTest() %7B%0A        int width = 6;%0A        int height = 5;%0A        %0A        SimpleGraph torus = makeTorus(width, height);%0A        System.out.println(torus);%0A        int diameter = Math.min(width, height);
+regularGraphTest(SimpleGraph graph, int diameter) %7B
 %0A   
@@ -1572,29 +1572,29 @@
 ature(0, h, 
-torus
+graph
 );%0A         
@@ -1735,21 +1735,21 @@
  1; i %3C 
-torus
+graph
 .getVert
@@ -1867,13 +1867,13 @@
  h, 
-torus
+graph
 );%0A 
@@ -1977,12 +1977,837 @@
  %7D%0A    %7D
+%0A    %0A    @Test%0A    public void torusTest() %7B%0A        int width = 6;%0A        int height = 5;%0A        %0A        SimpleGraph torus = makeTorus(width, height);%0A        System.out.println(torus);%0A        int diameter = Math.min(width, height);%0A        regularGraphTest(torus, diameter);%0A    %7D%0A    %0A    public SimpleGraph makeCompleteGraph(int n) %7B%0A        SimpleGraph g = new SimpleGraph();%0A        for (int i = 0; i %3C n; i++) %7B%0A            for (int j = i + 1; j %3C n; j++) %7B%0A                g.makeEdge(i, j);%0A            %7D%0A        %7D%0A        return g;%0A    %7D%0A    %0A    @Test%0A    public void completeGraphTest() %7B%0A        int n = 6;%0A        SimpleGraph kN = makeCompleteGraph(n);%0A        int expectedEdgeCount = (n * (n - 1)) / 2;%0A        Assert.assertEquals(expectedEdgeCount, kN.edges.size());%0A        regularGraphTest(kN, 2);%0A    %7D
 %0A%0A%7D%0A

Test complete graphs - is the diameter of a complete graph only 2?