Search code examples
pydot

Pydot parser : reading custom attributes in a node


I have dot graph string like

I know I can use node.get_name() or node.get_label() to read name/label.

what methods in the library can I use to read the custom properties like 'schema' or 'page' in the above case?

Posted in pydot github page. No response

"Graph_ID_1" [label="My graph" schema="my_schema" page=2];
}```

Solution

  • The get_attributes on nodes function will give you a dict with all the attributes.

    import pydot
    n = pydot.Node(my_attr="bar")
    print(n.get_attributes()) # -> {'my_attr': 'bar'}