How to use user-defined class object as a networkx node?
Class point is defined as (there are also some methods, atributes, and stuff in it, but this is minimal part): class point(): def ___init___(self, x, y): self.x = x self.y = y So, I saw this question , but when I tried applying it, it returns an error: G = nx.Graph() p = point(0,0) G.add_node(0, p) NetworkXError: The attr_dict argument must be a dictionary. If i use G = nx.Graph() p = point(0,0) G.add_node(0, data = p) I don't get an error, but when i try to access the x-coordinate, it turns out it didn't save it as a point. G[0].x returns: AttributeError: 'dict' object has no attribute 'x'