1

我刚刚安装了 Graphlab,并正在尝试将 NetworkX 代码转换为 Graphlab。我在 Graphlab 文档中找不到 NetworkX 等效的G.has_edge(). 如果不存在类似的功能,如何检查 Graphlab Edge 是否已存在于图中?

4

1 回答 1

1

SGraph.get_edges方法可用于检查是否存在特定边缘。在下面的示例中,我创建了一个“链”图,其中具有连续整数的顶点通过边连接。

>>> import graphlab
>>> g = graphlab.SGraph().add_edges(
        [graphlab.Edge(i, i+1) for i in range(4)])

# Edge does exist.
>>> test1 = g.get_edges(src_ids=[0], dst_ids=[1])
>>> test1.num_rows()
1

# Edge does *not* exist.
>>> test2 = g.get_edges(src_ids=[0], dst_ids=[2])
>>> test2.num_rows()
0

这是 API 文档的链接get_edgeshttps ://dato.com/products/create/docs/generated/graphlab.SGraph.get_edges.html

于 2016-02-17T22:16:42.870 回答