Writing a graph with custom node objects to gml file in Networkx

Viewed 97

I have a custom class called "Node" like this:

class Node:
def __init__(self, id,tableName, primaryKeys):
    self.id = id
    self.tableName = tableName
    self.primaryKeys = primaryKeys

The nodes of my graph are these custom Node objects, and the edges are between two Node objects. I am trying to write this graph into a gml file using Networkx's write_gml() function, but I get the following error:

networkx.exception.NetworkXError: <__main__.Node object at 0x7f940f5f4780> is not a string

The documentation says that I need a stringizer, but I could not find any examples on how to initialize a stringizer or how to use it to parse my Node class. Any comment or feedback is appreciated.

0 Answers
Related