示例#1
0
    def testAdjacencyList(self): 
        graph = DictGraph()
        graph.addEdge("a", "b", 1)
        graph.addEdge("b", "c", 1)
        graph.addEdge("b", "d", 1)
        graph.addEdge("c", "e", 1)
        graph.setVertex("f", 1)
 
        neighbourIndices, neighbourWeights = graph.adjacencyList()   
 
        vertexIds = graph.getAllVertexIds()

        for i in range(len(neighbourIndices)): 
            for k, j in enumerate(neighbourIndices[i]): 
                self.assertTrue(graph.edgeExists(vertexIds[i], vertexIds[j]))  
                self.assertEquals(graph[vertexIds[i], vertexIds[j]], neighbourWeights[i][k])