运行标签传播算法后在Graphframe上绘制python-igraph

时间:2019-06-06 20:11:09

标签: pyspark graph-algorithm graphframes python-igraph

我想使用python-igraph绘制我刚刚在其上运行LPA的GraphFrame。我了解有两种方法可以执行此操作,但是没有一种方法有效。有人可以帮忙吗?

第一种方法:在GraphFrame上运行LPA,然后绘制结果

# Generate an LPA graph
lpa_gf = author_keyword_lpa_gf.labelPropagation(maxIter=5).persist().show(10)
label_propagation = Graph.community_label_propagation(lpa_gf, weights=5)

# plot the graph
plot(lpa_gf, vertex_label=author_keyword_lpa_gf.vertices).save('graph2.2.png')

在这种情况下,lpa_gf变量以文本格式为我提供了正确的结果。但是,当我尝试绘制Graphframe时,出现一个错误,指出plot方法不能将lpa_gf作为输入。

第二种方法:直接在iGraph上运行LPA

label_propagation = Graph.community_label_propagation(author_keyword_lpa_gf, weights=5)

# plot the graph and display its legend
plot(label_propagation, vertex_label=author_keyword_lpa_gf.vertices).save('graph2.2.png')

在这种情况下,出现以下错误:

TypeError: descriptor 'community_label_propagation' for 'igraph.Graph' objects doesn't apply to 'GraphFrame' object

有人可以帮我弄清楚我在做什么错吗?

0 个答案:

没有答案