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 ...
随机推荐
- Python3NumPy——数组(1)之创建
开篇 numpy库作为科学计算的基础库,其地位相当重要,它是对数组操作的基石.它的存在使得线性代数以及矩阵论等相关知识在计算机上的表达更加方便与简单,集中体现出了人想办法,计算机去工作. Python ...
- Python求解啤酒问题(携程2016笔试题)
问题描述:一位酒商共有5桶葡萄酒和1桶啤酒,6个桶的容量分别为30升.32升.36升.38升.40升和62升,并且只卖整桶酒,不零卖.第一位顾客买走了2整桶葡萄酒,第二位顾客买走的葡萄酒是第一位顾客的 ...
- 【省带宽、压成本专题】从产品架构来看,PCDN如何节流50%
过去几年,我们一直在视频省流量方面潜心钻研,取得不俗的成果.本次"省带宽.压成本"系列一共会推出六篇文章,从技术迭代.硬件更新等角度出发,向大家介绍节省CDN流量,降低视频播放成本 ...
- ios11,弹出层内的input框光标错位 键盘弹出时,输入信息,光标一直乱跳
之前开发了一个微信项目,维护期中苹果手机突然出现光标错位现象,经过排查,发现是最新的ios11系统的锅. 具体情况:弹出层使用position: fixed:弹出层内附带input/textare ...
- 八:Vue下的国际化处理
p { margin-bottom: 0.25cm; line-height: 120% } 1:首先安装 Vue-i8n npm install vue-i18n --save 注:-save-de ...
- js变量的生命周期
1.在JavaScript中,对于for循环中定义的i变量,其生命周期在循环结束后仍然是有效的. for (var i=0; i < 10; i++){ doSomething(i); } al ...
- 迎圣诞,拿大奖活动赛题_SQLi(sprintf格式化字符)
看题目应该就是注入没跑了 先拿正常输入试试,输了admin,admin,结果返回password error!,说明还真的存在admin账户 拿常规注入语句试探一下admin' and 1=1%23, ...
- Python3玩转儿 机器学习(1)
机器学习的基础概念 数据 著名的鸢尾花数据 https://en.wikipedia.org/wiki/lris_flower_data_set lris setossa ...
- [SHOI2016]黑暗前的幻想乡
Description 四年一度的幻想乡大选开始了,最近幻想乡最大的问题是很多来历不明的妖 怪涌入了幻想乡,扰乱了幻想乡昔日的秩序.但是幻想乡的建制派妖怪(人类) 博丽灵梦和八云紫等人整日高谈所有妖怪 ...
- ●BZOJ 4566 [Haoi2016]找相同字符
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=4566题解: 广义后缀自动机 对两个串同时建立一个广义后缀自动机. 同时统计出每个状态对两个串 ...