pombreda / python-graph

Automatically exported from code.google.com/p/python-graph
Other
0 stars 0 forks source link

Cannot add a graph into a digraph #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
digraph.add_graph function fails as follows:

Traceback (most recent call last):
  File "/home/sal/workspace/python-graph/tests/unittests-digraph.py", line
195, in test_add_graph_into_diagraph
    d.add_graph( g )
  File "/home/sal/workspace/python-graph/core/pygraph/classes/digraph.py",
line 484, in add_graph
    self.add_edge(each_node, each_edge)
  File "/home/sal/workspace/python-graph/core/pygraph/classes/digraph.py",
line 222, in add_edge
    if (v not in self.node_neighbors[u] and self.node_neighbors[v] is not
None):
KeyError: 'B'

    def test_add_graph_into_diagraph(self):
        d = digraph()
        g = graph()

        A = "A"
        B = "B"

        g.add_node( A )
        g.add_node( B )
        g.add_edge( A,B )

        d.add_graph( g )

        assert d.has_node( A )
        assert d.has_node( B )
        assert d.has_edge( A,B )
        assert d.has_edge( B,A )  

Original issue reported on code.google.com by salimfadhley@gmail.com on 21 Oct 2009 at 12:27

GoogleCodeExporter commented 9 years ago
A fix to digraph.add_graph() and an additional unit-test has been added for 
your review.

Original comment by salimfadhley@gmail.com on 21 Oct 2009 at 12:29

GoogleCodeExporter commented 9 years ago
Seems to be correct. Could you update our Changelog to inform this fix, please?

Original comment by pmatiello on 21 Oct 2009 at 12:46

GoogleCodeExporter commented 9 years ago
Fixed by Salim.

Original comment by pmatiello on 27 Oct 2009 at 11:41