networkx edge 属性_networkx社交数据集(small)

  社交网络(social network):几个著名的社交网络。

1)karate_club_graph() 空手道俱乐部

返回 Zachary’s karate club graph

2)davis_southern_women_graph()

Returns Davis Southern women social network

3)florentine_families_graph()

Returns  Florentine families graph

4)Les_miserables_graph()

Returns  coappearance network of characters in the novel les miserable

1.  network.generators.social.karate_club_graph

karate_club_graph()

  • returns Zachary’s karate club graph. 返回扎卡利的空手道俱乐部

  • 返回的图中的每一个节点有一个“club”属性,表明该节点代表的成员是属于哪个俱乐部的,或者是“Mr Hi”,或者是“Officer”。

得到一个节点所属的俱乐部:

import networkx as nximport pandas as pdimport matplotlib.pyplot as pltG=nx.karate_club_graph()G.nodes[5]['club']
Out[26]: 'Mr. Hi'
G.nodes[9]['club']
Out[27]: 'Officer'
G1 = nx.davis_southern_women_graph()nodecolor=pd.DataFrame(G1.degree()).iloc[:,1]edgecolor=range(G1.number_of_edges())nx.draw(G1,with_labels=True, node_size=nodecolor*30,node_color=nodecolor*10,         edge_color=edgecolor,node_cmap=plt.cm.Blues)

ed00e056af717178d025496d1062c3f8.png

2. networkx.genertors.social.davis_southern_women_graph

davis_southern_women_graph()

  • Returns Davis southern women social network.

  • 这是一个二分图(bipartite graph)

G2 = nx.florentine_families_graph()nodecolor=pd.DataFrame(G2.degree()).iloc[:,1]edgecolor=range(G2.number_of_edges())nx.draw(G2,with_labels=True, node_size=nodecolor*30,node_color=nodecolor*10,        edge_color=edgecolor,node_cmap=plt.cm.Blues)

39dd4c7b8a384cad1b02700672c96afc.png

3.  networkx.generators.social.florentine_families_graph

Florentine_families_graph()

  • 返回佛罗伦萨家庭图

618d3438f993090a920db71f99034c74.png

4. networkx.generators.social.les_miserables_graph

les_miserables_graph()

  • 返回小说《悲惨世界》人物网络

2da8126e7490c464ad3e36f33eee18ef.png

总结:

Number of nodes

Number of edges

karate_club_graph()

34

78

davis_southern_women_graph()

32

89

Florentine_families_graph()

15

20

les_miserables_graph()

77

254

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值