【问题标题】:Python Connected Components from edges stream来自边缘流的 Python 连接组件
【发布时间】:2017-03-04 23:08:48
【问题描述】:

我想从边缘流中找到连接的组件

在输入中我有一个这样的流:

edges_in : [(e1,e2),(e2,e3),(e3,e1),(e5,e6)]
edges_out: : [(e1,e2)]

我正在寻找输出中的算法:

connected_edges : [[(e2,e3),(e3,e1)],[(e5,e6)]]

并且从这个 connected_edges 列表中有:

connected_nodes : [[e2,e3,e1],[e5,e6]]

我需要这个方法来维护组件

我已经在 python 中尝试了所有图形库(如 networkX、igraph)和在网络中的一些代码,但任何工作。

您的帮助很宝贵。

【问题讨论】:

    标签: python algorithm graph-algorithm


    【解决方案1】:

    看起来disjoint-set data structure 可以解决这个问题。

    此数据结构具有在线将元素加入组的能力。在每个组中,您可能都有带有已使用边缘的标签。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-12
      • 1970-01-01
      相关资源
      最近更新 更多