Reputation: 463
I need to display the attributes that were set for a node in GraphViz library.
from graphviz import Digraph
g = Digraph('G', filename='temp_graph.gv')
g.node(name='name', label='label', xlabel='xlabel', key1='value1', key2='value2')
g.view()
Currently, the result is as below. I need to show key1=value1 and key2=value2 also inside of the node.
Please let me know how may I display the graphviz node with its attributes.
Upvotes: 0
Views: 2714
Reputation: 318
Isn't that what the label attribute is for?
from graphviz import Digraph
g = Digraph('G', filename='temp_graph.gv')
g.node(name='name', label='key1: {}\nkey2: {}'.format( 'value1', 'value2' ), xlabel='xlabel', key1='value1', key2='value2')
g.view()
If you need to save the 'label' you can set it to a different attribute on the node
g.node(name='name', label='key1: {}\nkey2: {}'.format( 'value1', 'value2' ), mylabel="label", xlabel='xlabel', key1='value1', key2='value2')
Upvotes: 1