So I'm using a networkX graph to represent some information. This information is represented by different object types (for example, ColorNode and ShapeNode).
Some of the processing that is done on this graph requires me to extract out a specific type of node. Every time I need to do this, I do something along the lines of the code below.
colornodes = []
for node in graph.nodes():
if isinstance(node, ColorNode):
colornodes.append()
While this works, I feel like this is a situation that would arise often when working with graphs and I am re-inventing the wheel there. Essentially, I would like to know if there is a nicer way of doing this.