Reputation: 33
I am trying to gather data from twitter and visualize it through Graphviz. I have already installed Graphviz and currently I am trying to generate a DOT language output through Python, I ran into the problem of not being able to get any response from my code. I would like to know if my code has generated a DOT file or not and if yes, where is my DOT file? Below is my code.
OUT ="Paul_search_results.dot"
try:
nx.drawing.write_dot(g, OUT)
except ImportError, e:
dot = ['"%s" -> "&s" [tweet_id=%s]'% (n1, n2, g[n1][n2]['tweet_id'])\
for n1, n2 in g.edges()]
f = open(OUT, 'w')
f.write('strict digraph {\n%s\n}' % (';\n'.join(dot),))
f.close()
I am using windows and I know I can't easy_install pygraphviz
, but the code above should do the same thing. According to the book, I should have DOT language output on hand with the code above. But I didn't get any response from my code.
I already have gathered the information from twitter and the nodes and edges ready.
>>> g.number_of_nodes()
235
>>> g.number_of_edges()
202
Can somebody please help me out here?
Upvotes: 3
Views: 1175
Reputation: 226181
Your file is stored in Paul_search_results.dot
. If you can't find that find, then change the name to include the full path so you can put it where you want it.
The rest of the code looks correct but it is hard to tell without seeing the data. You set f=sys.stdout
in order to see the output being generated.
FYI, there is an on-line version of Graphviz available at http://interactive.blockdiag.com
Good luck with your project.
Upvotes: 1
Reputation: 104020
If nx.drawing.write_dot()
or f.write()
wrote any output to Paul_search_results.dot
, that file will be located in your "Current working directory". I haven't got a clue what Windows will set your current working directory to if you just double-click the file in Explorer.exe
-- it would be well worth your time to start a cmd.exe
command prompt, perform the cd
yourself to whichever directory you want to contain your output, run the command by hand, and then look over the console output to see if there are any error messages.
Upvotes: 1