public void HyperGraph_IsPartOfHexagon_has_to_work() { List <Vertex> vertices = new List <Vertex>(); List <HyperEdge> twoSidedEdges = new List <HyperEdge>(); for (int i = 0; i < 6; i++) { for (int j = i; j < 6; j++) { vertices.Add(new Vertex(i + "" + j)); if (i != j) { vertices.Add(new Vertex(j + "" + i)); } twoSidedEdges.Add(new HyperEdge(i + "" + j, j + "" + i)); } } HyperGraph hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } HyperEdge edge0 = new HyperEdge("00", "00", "00", TileOrientation.Straight); HyperEdge edge1 = new HyperEdge("00", "02", "20", TileOrientation.Flipped); HyperEdge edge2 = new HyperEdge("02", "22", "20", TileOrientation.DoubleTiltLeft); HyperEdge edge3 = new HyperEdge("01", "12", "20", TileOrientation.Flipped); HyperEdge edge4 = new HyperEdge("01", "11", "10", TileOrientation.DoubleTiltRight); HyperEdge edge5 = new HyperEdge("00", "01", "10", TileOrientation.TiltRight); List <Hexagon> hexagons = new List <Hexagon>(); HyperEdge addedEdge0 = hyperGraph.AddEdge(edge0); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out HyperEdge addedEdge1)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out HyperEdge addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out HyperEdge addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out HyperEdge addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out HyperEdge addedEdge5)); addedEdge5.AddDirectNeighbor(addedEdge0); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge1 = hyperGraph.AddEdge(edge1); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); addedEdge0.AddDirectNeighbor(addedEdge1); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge2 = hyperGraph.AddEdge(edge2); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out addedEdge1)); addedEdge1.AddDirectNeighbor(addedEdge2); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge3 = hyperGraph.AddEdge(edge3); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out addedEdge1)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); addedEdge2.AddDirectNeighbor(addedEdge3); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge4 = hyperGraph.AddEdge(edge4); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out addedEdge1)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); addedEdge3.AddDirectNeighbor(addedEdge4); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(1, hexagons.Count); //----------------------------------------------------------------------------------- hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge5 = hyperGraph.AddEdge(edge5); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge1, edge0, out addedEdge1)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); addedEdge4.AddDirectNeighbor(addedEdge5); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(1, hexagons.Count); //---------------------------------------------------------------------------------- HyperEdge edge6 = new HyperEdge("02", "24", "40", TileOrientation.DoubleTiltLeft); HyperEdge edge7 = new HyperEdge("04", "45", "50", TileOrientation.TiltLeft); HyperEdge edge8 = new HyperEdge("05", "55", "50", TileOrientation.Straight); HyperEdge edge9 = new HyperEdge("00", "05", "50", TileOrientation.TiltLeft); hyperGraph = new HyperGraph(vertices); foreach (HyperEdge twoSidedEdge in twoSidedEdges) { hyperGraph.AddEdge(twoSidedEdge); } addedEdge1 = hyperGraph.AddEdge(edge1); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge1, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge2, edge1, out addedEdge2)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge2, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge3, edge2, out addedEdge3)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge3, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge4, edge3, out addedEdge4)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge4, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge5, edge4, out addedEdge5)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge5, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge6, edge1, out HyperEdge addedEdge6)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge6, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge7, edge6, out HyperEdge addedEdge7)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge7, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge8, edge7, out HyperEdge addedEdge8)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge8, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge9, edge8, out HyperEdge addedEdge9)); Assert.IsFalse(hyperGraph.IsPartOfHexagon(edge9, out hexagons)); Assert.AreEqual(0, hexagons.Count); Assert.IsTrue(hyperGraph.AddEdgeWithDirectNeighbor(edge0, edge5, out addedEdge0)); addedEdge0.AddDirectNeighbor(addedEdge1); addedEdge0.AddDirectNeighbor(addedEdge9); Assert.IsTrue(hyperGraph.IsPartOfHexagon(edge0, out hexagons)); Assert.AreEqual(2, hexagons.Count); }