May-06-2023, 09:57 PM
(This post was last modified: May-06-2023, 09:58 PM by Gribouillis.)
(May-06-2023, 09:25 PM)6hearts Wrote: One idea, that would work, would be to keep track of the node type by a dictionaryYou don't need to do that, normally the Python type of the objects suffice. For example the vertices are instances of a class Vertex and the points are instances of a class Point. There is no need to maintain a dictionary to store the types.
def __init__(self, vertices, points): self._nodes = vertices + points self.kind = {v:"Vertex" for v in vertices} | {p:"Point" for p in points}