def test_numEdges(self): graph = g.newGraph(7,self.comparenames) g.insertVertex (graph, 'Bogota') g.insertVertex (graph, 'Yopal') g.insertVertex (graph, 'Cali') g.addEdge (graph, 'Bogota', 'Yopal') g.addEdge (graph, 'Bogota', 'Cali') n=g.numEdges(graph) lst = g.edges (graph) self.assertEqual (lt.size (lst), n)
def test_addEdges(self): graph = g.newGraph(7, self.comparenames) g.insertVertex(graph, 'Bogota') g.insertVertex(graph, 'Yopal') g.insertVertex(graph, 'Cali') g.insertVertex(graph, 'Medellin') g.insertVertex(graph, 'Pasto') g.insertVertex(graph, 'Barranquilla') g.insertVertex(graph, 'Manizales') g.addEdge(graph, 'Bogota', 'Yopal') g.addEdge(graph, 'Bogota', 'Medellin') g.addEdge(graph, 'Bogota', 'Pasto') g.addEdge(graph, 'Bogota', 'Cali') g.addEdge(graph, 'Yopal', 'Medellin') g.addEdge(graph, 'Medellin', 'Pasto') g.addEdge(graph, 'Cali', 'Pasto') g.addEdge(graph, 'Cali', 'Barranquilla') g.addEdge(graph, 'Barranquilla', 'Manizales') g.addEdge(graph, 'Pasto', 'Manizales') self.assertEqual(g.numEdges(graph), 10) self.assertEqual(g.numVertex(graph), 7) lst = g.vertices(graph) self.assertEqual(lt.size(lst), 7) lst = g.edges(graph) self.assertEqual(lt.size(lst), 10) degree = g.degree(graph, 'Bogota') self.assertEqual(degree, 4) edge = g.getEdge(graph, 'Bogota', 'Medellin') lst = g.adjacents(graph, 'Bogota') self.assertEqual(lt.size(lst), 4)