首页 > 编程知识 正文

社交网络分析属于什么可视化,社交网络分析论文

时间:2023-05-03 13:25:54 阅读:270822 作者:2750

社交网络算法可以识别强关系网络,若关系网络;基于好友关系为用户推荐商品或内容;社交网络中人物影响力的计算;金融行业中的反欺诈预测等等方面。

安装igraph pip install -U python-igraph

如果出现了错误,可以先下载下来,再安装:http://www.lfd.uci.edu/~gohlke/pythonlibs/

pip install wheelpip install python_igraph-0.7.1.post6-cp36-cp36m-win_amd64.whl  社交网络算法 ---分析指标  衡量指标: 度(degree) 密度(density)团(clique)度中心性(degree centrality)紧密中心性(closeness centrality) 介数中心性(betweenness centrality) 聚集系数(clustering coefficient) igraph里面包括的算法    pageRank算法社区发现算法(基于图结构) GN算法社区评价指标  模块度(modularity)阻断率(Conductance) 案例  权力的游戏里面的社交网络 import csvedges = []firstline = Truewith open('stormofswords.csv','r') as f: for row in csv.reader(f.read().splitlines()): if firstline == True: firstline = False continue u,v,weight = [i for i in row] edges.append((u,v,int(weight)))from igraph import Graph as IGraphg = IGraph.TupleList(edges,directed = True,vertex_name_attr="name",edge_attrs=None,weights = True)print(g)names = g.vs["name"]weights = g.es["weight"]print(names)print(weights)#网络直径:一个网络的直径被定义为网络中最长最短路径print(g.diameter())names = g.vs["name"]print(g.get_diameter)[names[x] for x in g.get_diameter()]#尝试下 "Jon"到“Margaery”之间的最短路径print(g.shortest_paths("Jon","Margaery"))print("---------------------") print([names[x] for x in g.get_shortest_paths("Jon","Margaery")[0]])print("---------------------")#看下“jon”paths = g.get_all_shortest_paths("Jon")for p in paths: print([names[x] for x in p])#度的中心性print(g.maxdegree())for p in g.vs: if p.degree() > 15: print(p["name"],p.degree())#最大的度为36个,说明最大的节点联结了36个边 #社区检测(community Detection)clusters = IGraph.community_walktrap(g,weights="weight").as_clustering()nodes = [{"name":node["name"]} for node in g.vs]community ={}for node in nodes: idx = g.vs.find(name=node["name"]).index node["community"] = clusters.membership[idx] if node["community"] not in community: community[node["community"]] = [node["name"]] else: community[node["community"]].append(node["name"])for c,l in community.items(): print("community",c,":",l)

 

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。