python - How to get the labels of nodes and egdes from read_dot -
i have dot file representing directed graph (digraph
). want read in networkx digraph object. used networkx.drawing.nx_agraph.read_dot(path)
, the nodes in graph function returns simple 'str'
types , labels lost in translation.
dotfile this:
digraph code { graph [bgcolor=white fontname="courier" splines="ortho"]; node [fillcolor=gray style=filled shape=box]; edge [arrowhead="normal"]; "0x000052c0" -> "0x00003a40" [label="section..text" color="red" url="section..text/0x00003a40"]; "0x00003a40" [label="section..text" url="section..text/0x00003a40"]; "0x000052c0" -> "0x0021ee08" [label="reloc.__libc_start_main_8" color="green" url="reloc.__libc_start_main_8/0x0021ee08"]; "0x0021ee08" [label="reloc.__libc_start_main_8" url="reloc.__libc_start_main_8/0x0021ee08"]; }
what wrote read file this:
import networkx nx g = nx.drawing.nx_agraph.read_dot(dot_graph_name)
does have better method? write own it's better have working , tested.
Comments
Post a Comment