python - My networkx graph is not displaying nodes with zero degree -


i have written simple python program using network library display graph. used graphviz visualization.

here code

import networkx nx  networkx.drawing.nx_pydot import write_dot  g2 = nx.read_edgelist("test_input.txt",create_using=nx.digraph())    write_dot(g2,"test_flow.doc") diagram = 'print (os.system("d:/graphviz/bin/dot -o ' + output.svg + ' -tsvg ' + test_flow.doc + '"))'  exec(diagram) 

test_input

a   b   c  b   d  d   e 

output graphviz

in case, dotfile not storing node "a".

nodes degree 0 not getting displayed. me in this?

the following directly networkx code. can see, "path" can read command. every line containing less 2 "words" ignored.

from source file:

for line in lines:     p=line.find(comments)     if p>=0:         line = line[:p]     if not len(line):         continue     # split line, should have 2 or more     s=line.strip().split(delimiter)     if len(s)<2:         continue     u=s.pop(0)     v=s.pop(0)     d=s 

this function in parse_edgelist. function read_edgelist wrapper around function posted.

i think best way parse manually file, retrieving "single" nodes , add them manually graph.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -