NetworkX: Subgraph Isomorphism by edge and node attributes

I've solved this by using:

print GM = iso.GraphMatcher(B,A,node_match=iso.categorical_node_match(['material', 'size'],['metal',1]))

What I didn't know before is that ['metal',1] is just a default and not a hard match.


You can iterate over all possible subgraphs in the following way

GM = networkx.algorithms.isomorphism.GraphMatcher(B,A)
for subgraph in GM.subgraph_isomorphisms_iter():
    print subgraph

subgraph in this example is a dictionary that maps nodes of B to nodes of A.

For the question of attribute matching, drum's suggestion has worked for me. Additional attribute matching actually speeds up things significantly for large graphs.