#StackBounty: #python-3.x #networkx Organizing a graph by node types: What is the most efficient way to collect nodes by type?

Bounty: 50


I’m creating a graph with many nodes where each node can represent one of many types of things. 5 cat nodes, 30 dog nodes, 40 people nodes, etc…

I’m currently assigning a ‘node_type’ attribute to each node and filtering over all nodes to collect nodes of a given type. I have to do this operation a lot and it feels very expensive and wrong. I’ve looked into bipartite graphs but they only support two groupings of nodes.


What is the best, most efficient way to organize and collect nodes of a given type?

I’ve looked at similar questions but this use case seems too common for a full graph search to be the correct answer.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.