创建回复网络
回复网络与转推网络的结构有明显差异。转推网络通常表示赞同,而回复则可能表示讨论、思考,甚至分歧。不过,其网络属性相同:网络是有向的,源节点是发起回复的人,目标节点是被回复的人。
在本练习中,您将基于另一份关于《国情咨文》(State of the Union)的推文样本来创建一个回复网络。这些推文已为您加载在 sotu_replies 中。
本练习是课程的一部分
在 Python 中分析社交媒体数据
练习说明
- 通过 pandas 的边列表创建回复网络。
- 将用户的屏幕名用作
source参数。 - 将被回复的屏幕名用作
target参数。 - 在
create_using参数中确保网络是有向图。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Import networkx
import networkx as nx
# Create reply network from edgelist
G_reply = ____.____(
sotu_replies,
____ = ____,
____ = ____,
____ = ____)
# Print the number of nodes
print('Nodes in reply network:', len(G_reply.nodes()))
# Print the number of edges
print('Edges in reply network:', len(G_reply.edges()))