Chris
unread,Jul 2, 2009, 2:24:13 PM7/2/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pydot
I am not sure of the intended usage of subgraphs with pydot. But
there appears to be a bug with subgraphs. If a subgraph is added to a
graph the obj_dict is saved, only. I believe this was done for
performance reasons as stated on your blog.
But when a user tries to retrieve a subgraph via a name, the
"get_subgraph" function will return a list of subgraphs. One Subgraph
for each obj_dict entry. In my example I created only one subgraph
and was returned 12 subgraphs. Below is a little example that
illustrates the issue.
This only worked when I modified get_subgraph to use the name argument
and not the non-existing sgraph variable.
There seems to be a 1 bug (use of sgraph in get_subgraph) and a
design / architecture issue in get_subgraph.
$ python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydot
>>> graph = pydot.Dot("graph")
>>> graph.add_node(pydot.Node("node1"))
>>> graph.add_node(pydot.Node("node2"))
>>> graph.add_subgraph(pydot.Subgraph("subgraph1"))
>>> graph.get_subgraph("subgraph1")
[<pydot.Subgraph object at 0x00DE20D0>, <pydot.Subgraph object at
0x00DE2110>, <pydot.Su
t at 0x00DFE5D0>, <pydot.Subgraph object at 0x00E02E10>,
<pydot.Subgraph object at 0x00E
>>> len(graph.get_subgraph("subgraph1"))
12
>>>
I don't believe the above example is the intended results. I believe
the intended usage would be for 1 Subgraph to be returned constructed
on the 12 dictionary values (obj_dict) saved. But instead a Subgraph
is created for each dict entry. This seems to be a common error with
all Subgraph functions.
Thanks
Chris