我正在使用 Networkx 函数进行同构:
GM = nx.algorithms.isomorphism.GraphMatcher(G1,G2,node_match=lambda n1,n2:n1['name']==n2['name'])
我想对一个名为“type”的边缘属性做同样的事情,但我不知道怎么做。我刚试过这个:
GM = nx.algorithms.isomorphism.GraphMatcher(G1,G2,node_match=lambda n1,n2:n1['name']==n2['name'], edge_match= lambda G[u1][v1],G2[u2][v2]: g[u1][v1]['type'] == g2[u2][v2]['type'])
但它不起作用。谢谢!
编辑:这是来自文档:
edge_match : callable
A function that returns True iff the edge attribute dictionary for
the pair of nodes (u1, v1) in G1 and (u2, v2) in G2 should be
considered equal during the isomorphism test. The function will be
called like::
edge_match(G1[u1][v1], G2[u2][v2])
That is, the function will receive the edge attribute dictionaries
of the edges under consideration. If None, then no attributes are
considered when testing for an isomorphism.