如何为网络中的节点分配多个标签/标签/标识符

问题描述

我有一个关于网络中节点标签的问题。我想添加一些额外的标签来标识一些满足条件 (Trusted=1) 的节点。

数据集包含以下列:

ID              Friend          #_Posts #_Likes Community   Trusted 
1241            014                62       50     Red           1
1241            153                580      120    Green         1
023             152                98       1      Red           0
014             014               1980      2104   Red           0

我正在使用网络来创建网络:

import networkx as nx
import matplotlib.pyplot as plt

G = nx.from_pandas_edgelist(df,source='ID',target='Friends',edge_attr='#_Likes')

pos=nx.spring_layout(G)

nx.draw_networkx_nodes(G,pos,node_size = 400,node_color=df['Community'])
nx.draw_networkx_edges(G,width = [I['#_Likes']for i in dict(G.edges).values()])

我想要一个网络,其中节点的大小基于#_Posts,边的权重基于#_Likes。社区应该为每个节点 ID 分配一种颜色。我还想有一个标志/标签来区分可信 (1) 和不可信 (0)。你能告诉我怎么做吗?

enter image description here

(而不是 +/-,我会放 1/0)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)