【问题标题】:More number of nodes in bipartite projection than node set二分投影中的节点数量多于节点集
【发布时间】:2013-02-15 15:16:15
【问题描述】:

我将一个图投影到它的一个节点集上,但是生成的投影比原始节点集有更多的节点,而且奇怪的是,这个“额外”节点只是一个与 G 中的节点 id 对应的数字,而不是完整的(节点,数据)元组。

C=set(n for n,d in G.nodes(data=True) if d['bipartite']==0)
len(C)
>>109813
BC=bipartite.projected_graph(G,C)
len(BC)
>>112570
len(BC)-len(C)
>>2757

BC 的所有“额外”节点都只是一个数字(对应于 G 中的节点 id)。这个“额外”的 2757 个节点来自哪里?我希望二分投影图的节点数量与其投影到的节点集中的节点数量相同。有什么想法吗?

可能的额外有用信息:

len(G)
>>117679

【问题讨论】:

    标签: python graph networkx


    【解决方案1】:

    您的图表可能不是关于您的节点集的二分图, 例如

    In [1]: import networkx as nx
    
    In [2]: from networkx import bipartite
    
    In [3]: G = nx.path_graph(5) # two parts, [0,2,4],[1,3]
    
    In [4]: bipartite.projected_graph(G,[0,2,4]).nodes()
    Out[4]: [0, 2, 4] # OK
    
    In [5]: bipartite.projected_graph(G,[0,2,3]).nodes()
    Out[5]: [0, 1, 2, 3, 4] # maybe not expected or correct
    

    这可能被认为是一个错误,但文档确实警告说在进行投影之前没有进行双向检查。

    【讨论】:

      猜你喜欢
      • 2021-10-24
      • 2020-10-04
      • 2022-09-27
      • 2017-02-27
      • 1970-01-01
      • 1970-01-01
      • 2021-11-10
      • 2016-02-09
      • 2015-01-05
      相关资源
      最近更新 更多