cudadog / pydot

Automatically exported from code.google.com/p/pydot
MIT License
0 stars 0 forks source link

Error while trying to run example pydot script on dkbza.org #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Copy the example pydot Python script into a file:

$ cat example.py
import pydot

edges=[(1,2), (1,3), (1,4), (3,4)]
g=pydot.graph_from_edges(edges)
g.write_jpeg('graph_from_edges_dot.jpg', prog='dot')

2. Run this script:

$ python example.py
Traceback (most recent call last):
  File "example.py", line 4, in ?
    g=pydot.graph_from_edges(edges)
  File "/d0/home/sramapra/personal/pydot-read-only/pydot.py", line 237, in
graph_from_edges
    e = Edge( node_prefix + edge[0], node_prefix + edge[1] )
TypeError: cannot concatenate 'str' and 'int' objects

What is the expected output? What do you see instead?

I should get a jpeg file that contains the graph.  I instead see the
traceback mentioned above.

What version of the product are you using? On what operating system?

$ uname -a
Linux arakkis 2.6.18.8-0.11-default #1 SMP Sat Oct 11 16:17:11 UTC 2008
x86_64 x86_64 x86_64 GNU/Linux

From pydot help:
VERSION
    1.0.2

Comments:

It appears that simply coercing the edge elements to strings will fix the
issue:
    e = Edge( node_prefix + str( edge[0] ), node_prefix + str( edge[1] ) )

Original issue reported on code.google.com by shashank...@gmail.com on 17 Oct 2008 at 10:23

GoogleCodeExporter commented 9 years ago
I am not sure how exactly to submit a patch, but this should fix the issue:

$ svn diff pydot.py
Index: pydot.py
===================================================================
--- pydot.py    (revision 9)
+++ pydot.py    (working copy)
@@ -234,7 +234,7 @@

     for edge in edge_list:

-        e = Edge( node_prefix + edge[0], node_prefix + edge[1] )
+        e = Edge( node_prefix + str(edge[0]), node_prefix + str(edge[1]) )
         graph.add_edge(e)

     return graph

Original comment by shashank...@gmail.com on 17 Oct 2008 at 10:34

GoogleCodeExporter commented 9 years ago
Patch worked for me. Thanks.

Original comment by chris...@gmail.com on 12 Dec 2008 at 5:37

GoogleCodeExporter commented 9 years ago
Thanks for the patch!
I also had to do the following (I am using pydot with Networkx):
diff pydot-1.0.2/pydot.py pydot-1.0.2_patched/pydot.py
237,238c237,238
<         e = Edge( node_prefix + edge[0], node_prefix + edge[1] )
<         graph.add_edge(e)
---
>   e = Edge( node_prefix + str(edge[0]), node_prefix + str(edge[1]) )
>   graph.add_edge(e)
900c900
<             edge_attr.append( attr + '=' + quote_if_necessary(value) )
---
>             edge_attr.append( attr + '=' + str(quote_if_necessary(value)) )

Original comment by simon.kn...@gmail.com on 15 Oct 2009 at 4:29

GoogleCodeExporter commented 9 years ago
Works for me, can this be committed?

Original comment by dgtlm...@gmail.com on 8 Dec 2009 at 1:41

GoogleCodeExporter commented 9 years ago
I'd like to see this fixed ASAP as I have code that depends on it (and that 
needs to be deployed) - so I can't 
depend on other users having a modified version of pydot installed.

Original comment by dru...@gmail.com on 13 Dec 2009 at 8:32

GoogleCodeExporter commented 9 years ago

Original comment by ero.carr...@gmail.com on 30 Oct 2010 at 11:54