Esempio n. 1
0
 def test_edges(self):
     g = DGraph()
     g.add_node('1', label='kekek')
     g.add_node('2')
     g.add_node('3')
     g.add_node('4')
     g.add_edge('1', '2', weight=2)
     g.add_edge('3', '2', weight=2)
     self.assertEqual(len(g.edges()), 2, "wrong number of edges ")
Esempio n. 2
0
    def test_nodes(self):
        g = DGraph()
        g.add_node('1', label='kekek')
        g.add_node('2')
        g.add_node('3')
        g.add_node('4')

        self.assertEqual(len(g.nodes()), 4, "wrong number of nodes ")
        self.assertEqual(set(g.nodes()), {'1', '2', '3', '4'},
                         "wrong set of nodes")
Esempio n. 3
0
 def test_builtgraph_export(self):
     g = DGraph()
     g.add_node('1', label='kekek')
     g.add_node('2')
     g.add_node('3')
     g.add_node('4')
     g.add_edge('1', '2', weight=2)
     g.add_edge('3', '2', weight=2)
     g.write_dot(join(project_root(), "./tests/dot_export/g.dot"))
     g2 = DGraph.read_dot(join(project_root(), "./tests/dot_export/g.dot"))
     assert g2.dgraph is not None
     self.assertEqual(len(g.nodes()), 4,
                      "wrong number of nodes after export")
     self.assertEqual(len(g.edges()), 2,
                      "wrong number of edges after export")
     assert nx.algorithms.is_isomorphic(g.dgraph, g2.dgraph)