admin管理员组文章数量:1122832
I am implementing a graph grammar using networkx that grows as it finds certain subgraphs, however, the above functions do not always work as expected. I found out that it depends not on the graphs and/or subgraphs themselves, but on the order in which the edges are arranged in the object. How can I solve this?
For example: a graph "initial" has:
0:u
1:u
2:u
3:u
4:u
5:u
134:u
135:u
0:u 2:u
2:u 4:u
3:u 134:u
3:u 135:u
4:u 3:u
5:u 135:u
134:u 5:u
135:u 1:u
When I apply two subgraphs: subg1 =
1:*
2:u
0:*
1:* 2:u
2:u 0:*
```
[![enter image description here][2]][2]
and
subg2 =
```
1:*
2:u
0:*
2:u 1:*
0:* 2:u
The code is:
GM = iso.DiGraphMatcher(initial, subg1, node_match=iso.generic_node_match('label', '@', initialpare_nodes) )
res = list(GM.subgraph_monomorphisms_iter())
print(res)
I can obtain:
[{2:u: 1:*, 4:u: 2:u, 3:u: 0:*},
{134:u: 1:*, 5:u: 2:u, 135:u: 0:*},
{3:u: 1:*, 134:u: 2:u, 5:u: 0:*},
{3:u: 1:*, 135:u: 2:u, 1:u: 0:*},
{5:u: 1:*, 135:u: 2:u, 1:u: 0:*},
{4:u: 1:*, 3:u: 2:u, 134:u: 0:*},
{4:u: 1:*, 3:u: 2:u, 135:u: 0:*}]
But, when I apply
GM = iso.DiGraphMatcher(initial, subg2, node_match=iso.generic_node_match('label', '@', initialpare_nodes) )
res = list(GM.subgraph_monomorphisms_iter())
print(res)
I obtain an empty list. Besides, I could not get {"0:u", "2:u", "4:u"}
sequence.
本文标签:
版权声明:本文标题:graph - "subgraph_monomorphisms_iter()" and "subgraph_isomorphisms_iter()" depends on order 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299501a1930476.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论