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 test_SpecifyThatNavGraphNodeEdgesCanBeModifiedWithAWeighting(self):
        graph = self.CreateGraphGrid()

        self.assertAlmostEqual(50.0, graph._edgeListVector[0][0].Cost, 1,
                               "graph._edgeListVector[0][0].Cost 1")
        self.assertAlmostEqual(50.0, graph._edgeListVector[0][1].Cost, 1,
                               "graph._edgeListVector[0][1].Cost 1")
        self.assertAlmostEqual(70.7, graph._edgeListVector[0][2].Cost, 1,
                               "graph._edgeListVector[0][2].Cost 1")

        GraphTools.WeightNavGraphNodeEdges(graph, 0, 2)

        self.assertAlmostEqual(100.0, graph._edgeListVector[0][0].Cost, 1,
                               "graph._edgeListVector[0][0].Cost 2")
        self.assertAlmostEqual(100.0, graph._edgeListVector[0][1].Cost, 1,
                               "graph._edgeListVector[0][1].Cost 2")
        self.assertAlmostEqual(141.4, graph._edgeListVector[0][2].Cost, 1,
                               "graph._edgeListVector[0][2].Cost 2")