我想在python中使用
networkx
如所解释的
here
我有一个数据帧,它包含两个节点之间的edgelist
i
和
j
df
i j
0 A B
1 B C
2 B A
3 C A
4 C B
对于每个节点我都有一个标签
0
或
1
.
dfN
Node Label
0 A 0
1 B 1
2 C 0
我创建了网络
import networkx as nx
g = nx.from_pandas_edgelist(df, 'A', 'B')
现在我想运行PPR
ppr1 = nx.pagerank(g,personalization={A:0, B:1, C:0})
如何创建
dict
{A:0, B:1, C:0}
直接从
dfN
?