python复杂网络库networkx:算法
http://blog.csdn.net/pipisorry/article/details/54020333
Networks算法Algorithms
最短路径Shortest Paths
简单路径Simple Paths
all_simple_paths(G, source, target[, cutoff]) |
Generate all simple paths in the graph G from source to target. |
shortest_simple_paths(G, source, target[, ...]) |
Generate all simple paths in the graph G from source to target, starting from shortest ones. |
Note:nx.all_simple_paths只能迭代一次。
链接分析Link Analysis
PageRank Hits
链接预测Link Prediction
链接预测算法
resource_allocation_index(G[, ebunch]) |
Compute the resource allocation index of all node pairs in ebunch. |
jaccard_coefficient(G[, ebunch]) |
Compute the Jaccard coefficient of all node pairs in ebunch. |
adamic_adar_index(G[, ebunch]) |
Compute the Adamic-Adar index of all node pairs in ebunch. |
preferential_attachment(G[, ebunch]) |
Compute the preferential attachment score of all node pairs in ebunch. |
cn_soundarajan_hopcroft(G[, ebunch, community]) |
Count the number of common neighbors of all node pairs in ebunch using community information. |
ra_index_soundarajan_hopcroft(G[, ebunch, ...]) |
Compute the resource allocation index of all node pairs in ebunch using community information. |
within_inter_cluster(G[, ebunch, delta, ...]) |
Compute the ratio of within- and inter-cluster common neighbors of all node pairs in ebunch. |
Note: 返回的基本都是iterator of 3-tuples in the form (u, v, p)。iterator只能迭代一次,否则为空了。
不指定ebunch的话就是计算所有没有边的点。If ebunchis None then all non-existent edges in the graph will be used.
单纯cn个数的计算
def commonNeighbor(G, ebunch=None):
'''
compute num of common neighbor
'''
import networkx as nx
if ebunch is None:
ebunch = nx.non_edges(G)
def predict(u, v):
cnbors = list(nx.common_neighbors(G, u, v))
return len(cnbors)
return ((u, v, predict(u, v)) for u, v in ebunch)
组件Components
connectivity连通性
连通子图Connected components
is_connected(G) |
Return True if the graph is connected, false otherwise. |
number_connected_components(G) |
Return the number of connected components. |
connected_components(G) |
Generate connected components. |
connected_component_subgraphs(G[, copy]) |
Generate connected components as subgraphs. |
node_connected_component(G, n) |
Return the nodes in the component of graph containing node n. |
连通子图计算示例
from networkx.algorithms import traversal, components
weighted_edges = pd.read_csv(os.path.join(CWD, 'middlewares/network_reid.txt'), sep=',',
header=None).values.tolist()
g = nx.Graph()
g.add_weighted_edges_from(weighted_edges)
# print('#connected_components of g: {}'.format(nx.number_connected_components(g)))
component_subgs = components.connected_component_subgraphs(g)
for component_subg in component_subgs:
])
Strong connectivity
Weak connectivity
Attracting components
Biconnected components
Semiconnectedness
Connectivity
Connectivity and cut algorithms
遍历Traversal
深度优先遍历
广度优先遍历
边的深度优先遍历
networkx算法示例
使用networkx计算所有路径及路径距离
[jupyter]
[python—networkx:求图的平均路径长度并画出直方图]
社区发现
[复杂网络社区结构发现算法-基于python networkx clique渗透算法 ]
from: http://blog.csdn.net/pipisorry/article/details/54020333
ref: [Algorithms]
[Networkx Reference]*[NetworkX documentation]*[doc NetworkX Examples]*[NetworkX Home]
python复杂网络库networkx:算法的更多相关文章
- python复杂网络库networkx:基础
http://blog.csdn.net/pipisorry/article/details/49839251 其它复杂网络绘图库 [SNAP for python] [ArcGIS,Python,网 ...
- python复杂网络库networkx:绘图draw
http://blog.csdn.net/pipisorry/article/details/54291831 networkx使用matplotlib绘制函数 draw(G[, pos, ax, h ...
- Python 并发网络库
Python 并发网络库 Tornado VS Gevent VS Asyncio Tornado:并发网络库,同时也是一个 web 微框架 Gevent:绿色线程(greenlet)实现并发,猴子补 ...
- python复杂网络分析库NetworkX
NetworkX是一个用Python语言开发的图论与复杂网络建模工具,内置了常用的图与复杂网络分析算法,可以方便的进行复杂网络数据分析.仿真建模等工作.networkx支持创建简单无向图.有向图和多重 ...
- Python常用的库简单介绍一下
Python常用的库简单介绍一下fuzzywuzzy ,字符串模糊匹配. esmre ,正则表达式的加速器. colorama 主要用来给文本添加各种颜色,并且非常简单易用. Prettytable ...
- 使用python网络库下载
下载1000次网页资源 1,普通循环方式下载1000次,非常慢 #!/usr/bin/python # -*- coding: utf-8 -*- import sys import os impor ...
- python基于协程的网络库gevent、eventlet
python网络库也有了基于协程的实现,比较著名的是 gevent.eventlet 它两之间的关系可以参照 Comparing gevent to eventlet, 本文主要简单介绍一下event ...
- day-9 sklearn库和python自带库实现最近邻KNN算法
K最近邻(k-Nearest Neighbor,KNN)分类算法,是一个理论上比较成熟的方法,也是最简单的机器学习算法之一.该方法的思路是:如果一个样本在特征空间中的k个最相似(即特征空间中最邻近)的 ...
- python爬虫#网络请求requests库
中文文档 http://docs.python-requests.org/zh_CN/latest/user/quickstart.html requests库 虽然Python的标准库中 urlli ...
随机推荐
- if else if,switch case二者的联系与区别
前段时间在学习中听到了一个关于条件判断语句的问题,分析if else if语句和switch case语句这两者之间的联系和区别,从而使用其中最有效率的一种方法. 一.if...else if if. ...
- app 下载更新 file-downloader 文件下载库的简单介绍和使用
app 下载更新 file-downloader 文件下载库的简单介绍和使用 今天介绍一个下载库:file-downloader 文件下载库 说明: * 本文内容来自原 file-downloader ...
- selenium 设置代理的话,可以使用这种方式,代码是我刚才测试过的,亲测可用
from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_argumen ...
- [LeetCode] Kill Process 结束进程
Given n processes, each process has a unique PID (process id) and its PPID (parent process id). Each ...
- localStorage学习总结
一.本地存储 在HTML5诞生之前,网站如果想在浏览器端存储数据,只能使用Cookie,使用Cookie有较多的限制. Cookie问题: 1.cookie大小限制在4K左右(各个浏览器不一致) 2. ...
- [HNOI 2010]Planar
Description 题库链接 给出 \(T\) 个 \(N\) 个节点 \(M\) 条边的无向图(无重边自环),并给出它们各自的哈密顿回路.分别判断每个图是否是平面图. \(T\leq 100,3 ...
- CTSC&APIO2017
CTSC Day -1 因为越发感到自己与dalao们之间姿势水平的差距,本来打算再多学些姿势,但被老师叫去做noi,于是花了一两周的时间做完了noi2011~2015,也学到了一些奇怪姿势,还是挺有 ...
- hdu4542 && ZOJ2562(反素数)
反素数: 对于任何正整数,其约数个数记为,例如,如果某个正整数满足:对任意的正整 数,都有,那么称为反素数. 有两个特点: 1.一个反素数的质因子必是从2开始的质数 2.如果,那么必有 最常见的问题如 ...
- [bzoj4815]: [Cqoi2017]小Q的表格
来自FallDream的博客,未经允许,请勿转载,谢谢. 小Q是个程序员. 作为一个年轻的程序员,小Q总是被老C欺负,老C经常把一些麻烦的任务交给小Q来处理.每当小Q不知道如何解决时,就只好向你求助. ...
- [BZOJ]1031 字符加密Cipher(JSOI2007)
持续划水中…… 感觉BZOJ上AC人数多的基本都是一些模板题,也就是某些算法的裸题.这些题目mark一下到时候回来复习也是不错的选择. Description 喜欢钻研问题的JS同学,最近又迷上了对加 ...