【问题标题】:getting a list of matching nodes in networkx获取networkx中匹配节点的列表
【发布时间】:2012-12-04 06:27:55
【问题描述】:

目前我已经确定两个图是同构的(根据我的定义),我想要一个在 is_isomorphic() 期间匹配的节点列表。有这样做的功能吗?

应该提到我正在使用networkx。

【问题讨论】:

    标签: python networkx


    【解决方案1】:

    您可以检索两个图之间的同构映射。那会吗?见here

    >>> from networkx.algorithms import isomorphism
    >>> G1 = nx.path_graph(4)
    >>> G2 = nx.path_graph(4)
    >>> GM = isomorphism.GraphMatcher(G1,G2)
    >>> GM.is_isomorphic()
    True
    >>> GM.mapping
    {0: 0, 1: 1, 2: 2, 3: 3}
    

    【讨论】:

      猜你喜欢
      • 2016-09-15
      • 1970-01-01
      • 2021-10-23
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2017-10-12
      • 1970-01-01
      相关资源
      最近更新 更多