def CreateGraphGrid():
     graph = SparseGraph.CreateNavGraph(isDigraph=False)
     GraphTools.CreateGrid(graph, cxSize=50 * 3, cySize=50 * 3, numCellsX=3, numCellsY=3)
     GraphTools.WeightNavGraphNodeEdges(graph, nodeIndex=1, weight=2.5)
     GraphTools.WeightNavGraphNodeEdges(graph, nodeIndex=4, weight=2.5)
     GraphTools.WeightNavGraphNodeEdges(graph, nodeIndex=6, weight=2.5)
     return graph
 def CreateGraphGrid(size=3):
     graph = SparseGraph.CreateNavGraph(isDigraph=False)
     GraphTools.CreateGrid(graph,
                           cxSize=50 * size,
                           cySize=50 * size,
                           numCellsX=size,
                           numCellsY=size)
     return graph
 def CreateGraphGrid():
     graph = SparseGraph.CreateNavGraph(isDigraph=False)
     GraphTools.CreateGrid(graph,
                           cxSize=50 * 3,
                           cySize=50 * 3,
                           numCellsX=3,
                           numCellsY=3)
     return graph
    def test_SpecifyThatAConnectedGridCanBeConstructedOnAUniGraph(self):
        graph = SparseGraph.CreateNavGraph(isDigraph=False)

        GraphTools.CreateGrid(graph,
                              cxSize=50 * 3,
                              cySize=50 * 3,
                              numCellsX=3,
                              numCellsY=3)

        self.assertEqual(9, len(graph._nodes), "_nodes")
        self.assertEqual(9, len(graph._edgeListVector), "_edgeListVector")
        self.assertEqual(9, graph._nextNodeIndex, "_nextNodeIndex")
        self.assertEqual(40, graph.NumberOfEdges(), "NumberOfEdges")

        self.assertEqual(0, graph._nodes[0].Index, "_nodes[0].Index")
        self.assertEqual(1, graph._nodes[1].Index, "_nodes[1].Index")
        self.assertEqual(2, graph._nodes[2].Index, "_nodes[2].Index")
        self.assertEqual(3, graph._nodes[3].Index, "_nodes[3].Index")
        self.assertEqual(4, graph._nodes[4].Index, "_nodes[4].Index")
        self.assertEqual(5, graph._nodes[5].Index, "_nodes[5].Index")
        self.assertEqual(6, graph._nodes[6].Index, "_nodes[6].Index")
        self.assertEqual(7, graph._nodes[7].Index, "_nodes[7].Index")
        self.assertEqual(8, graph._nodes[8].Index, "_nodes[8].Index")

        self.assertEqual(3, len(graph._edgeListVector[0]),
                         "_edgeListVector[0]")
        self.assertEqual(5, len(graph._edgeListVector[1]),
                         "_edgeListVector[1]")
        self.assertEqual(3, len(graph._edgeListVector[2]),
                         "_edgeListVector[2]")
        self.assertEqual(5, len(graph._edgeListVector[3]),
                         "_edgeListVector[3]")
        self.assertEqual(8, len(graph._edgeListVector[4]),
                         "_edgeListVector[4]")
        self.assertEqual(5, len(graph._edgeListVector[5]),
                         "_edgeListVector[5]")
        self.assertEqual(3, len(graph._edgeListVector[6]),
                         "_edgeListVector[6]")
        self.assertEqual(5, len(graph._edgeListVector[7]),
                         "_edgeListVector[6]")
        self.assertEqual(3, len(graph._edgeListVector[8]),
                         "_edgeListVector[6]")

        self.assertEqual(1, graph._edgeListVector[0][0].To,
                         "graph._edgeListVector[0][0].To")
        self.assertEqual(3, graph._edgeListVector[0][1].To,
                         "graph._edgeListVector[0][1].To")
        self.assertEqual(4, graph._edgeListVector[0][2].To,
                         "graph._edgeListVector[0][2].To")

        self.assertEqual(0, graph._edgeListVector[1][0].To,
                         "graph._edgeListVector[1][0].To")
        self.assertEqual(2, graph._edgeListVector[1][1].To,
                         "graph._edgeListVector[1][1].To")
        self.assertEqual(3, graph._edgeListVector[1][2].To,
                         "graph._edgeListVector[1][2].To")
        self.assertEqual(4, graph._edgeListVector[1][3].To,
                         "graph._edgeListVector[1][3].To")
        self.assertEqual(5, graph._edgeListVector[1][4].To,
                         "graph._edgeListVector[1][4].To")

        self.assertEqual(1, graph._edgeListVector[2][0].To,
                         "graph._edgeListVector[2][0].To")
        self.assertEqual(4, graph._edgeListVector[2][1].To,
                         "graph._edgeListVector[2][1].To")
        self.assertEqual(5, graph._edgeListVector[2][2].To,
                         "graph._edgeListVector[2][2].To")

        self.assertEqual(0, graph._edgeListVector[3][0].To,
                         "graph._edgeListVector[3][0].To")
        self.assertEqual(1, graph._edgeListVector[3][1].To,
                         "graph._edgeListVector[3][1].To")
        self.assertEqual(4, graph._edgeListVector[3][2].To,
                         "graph._edgeListVector[3][2].To")
        self.assertEqual(6, graph._edgeListVector[3][3].To,
                         "graph._edgeListVector[3][3].To")
        self.assertEqual(7, graph._edgeListVector[3][4].To,
                         "graph._edgeListVector[3][4].To")

        self.assertEqual(0, graph._edgeListVector[4][0].To,
                         "graph._edgeListVector[4][0].To")
        self.assertEqual(1, graph._edgeListVector[4][1].To,
                         "graph._edgeListVector[4][1].To")
        self.assertEqual(2, graph._edgeListVector[4][2].To,
                         "graph._edgeListVector[4][2].To")
        self.assertEqual(3, graph._edgeListVector[4][3].To,
                         "graph._edgeListVector[4][3].To")
        self.assertEqual(5, graph._edgeListVector[4][4].To,
                         "graph._edgeListVector[4][4].To")
        self.assertEqual(6, graph._edgeListVector[4][5].To,
                         "graph._edgeListVector[4][5].To")
        self.assertEqual(7, graph._edgeListVector[4][6].To,
                         "graph._edgeListVector[4][6].To")
        self.assertEqual(8, graph._edgeListVector[4][7].To,
                         "graph._edgeListVector[4][7].To")

        self.assertEqual(1, graph._edgeListVector[5][0].To,
                         "graph._edgeListVector[5][0].To")
        self.assertEqual(2, graph._edgeListVector[5][1].To,
                         "graph._edgeListVector[5][1].To")
        self.assertEqual(4, graph._edgeListVector[5][2].To,
                         "graph._edgeListVector[5][2].To")
        self.assertEqual(7, graph._edgeListVector[5][3].To,
                         "graph._edgeListVector[5][3].To")
        self.assertEqual(8, graph._edgeListVector[5][4].To,
                         "graph._edgeListVector[5][4].To")

        self.assertEqual(3, graph._edgeListVector[6][0].To,
                         "graph._edgeListVector[6][0].To")
        self.assertEqual(4, graph._edgeListVector[6][1].To,
                         "graph._edgeListVector[6][1].To")
        self.assertEqual(7, graph._edgeListVector[6][2].To,
                         "graph._edgeListVector[6][2].To")

        self.assertEqual(3, graph._edgeListVector[7][0].To,
                         "graph._edgeListVector[7][0].To")
        self.assertEqual(4, graph._edgeListVector[7][1].To,
                         "graph._edgeListVector[7][1].To")
        self.assertEqual(5, graph._edgeListVector[7][2].To,
                         "graph._edgeListVector[7][2].To")
        self.assertEqual(6, graph._edgeListVector[7][3].To,
                         "graph._edgeListVector[7][3].To")
        self.assertEqual(8, graph._edgeListVector[7][4].To,
                         "graph._edgeListVector[7][4].To")

        self.assertEqual(4, graph._edgeListVector[8][0].To,
                         "graph._edgeListVector[8][0].To")
        self.assertEqual(5, graph._edgeListVector[8][1].To,
                         "graph._edgeListVector[8][1].To")
        self.assertEqual(7, graph._edgeListVector[8][2].To,
                         "graph._edgeListVector[8][2].To")