Analyzing Complex Networks with Python
| Author | Version | Demo |
|---|---|---|
| Gialdetti |
netsci is a python package for efficient statistical analysis of spatially-embedded networks. In addition, it offers several algorithms and implementations (CPU and GPU-based) of motif counting algorithms.
For other models and metrics, we highly recommend using existing and richer tools. Noteworthy packages are the magnificent NetworkX, graph-tool or Brain Connectivity Toolbox.
Analyzing a star network (of four nodes)
import numpy as np
import netsci.visualization as nsv
A = np.array([[0,1,1,1], [0,0,0,0], [0,0,0,0], [0,0,0,0]])
nsv.plot_directed_network(A, pos=[[0,0],[-1,1],[1,1],[0,-np.sqrt(2)]])import netsci.metrics.motifs as nsm
f = nsm.motifs(A, algorithm='brute-force')
print(f)
# [1 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0]nsv.bar_motifs(f)Using GPU for the motif counting is easy
from netsci.models.random import erdos_renyi
# Create an Erdős–Rényi network, and count motifs using a GPU
A_er = erdos_renyi(n=500, p=0.2, random_state=71070)
f_er = nsm.motifs(A_er, algorithm="gpu")
# Visualize
print(f_er)
# [5447433 8132356 1031546 2023563 1011703 1011109 503098 512458
# 513352 167427 64844 127751 64442 63548 32483 1387]
nsv.bar_motifs(f_er)The running-time speedup ratio resulting from the GPU-based implementation, as measured over several networks sizes (n) and sparsities (p), is depicted below
A full a live notebook for performing this benmarching is provided below.
Install latest release version via pip
pip install netscivia pip
pip install git+https://github.com/gialdetti/netsci.gitor, in development mode
git clone https://github.com/gialdetti/netsci.git
cd netsci
pip install -e .[dev]After installation, you can launch the test suite:
pytest| Theme | MyBinder | Colab |
|---|---|---|
| Basic network motifs demo | ||
| Connectomics dataset, and 3-neuron motif embedding | ||
| Tech: GPU speedup of motif analysis |
Please send any questions you might have about the code and/or the algorithm to eyal.gal@mail.huji.ac.il.
If you use netsci in a scientific publication, please consider citing the following paper:
Gal, E., Perin, R., Markram, H., London, M., and Segev, I. (2019). Neuron Geometry Underlies a Universal Local Architecture in Neuronal Networks. BioRxiv 656058.
Bibtex entry:
@article {Gal2019
author = {Gal, Eyal and Perin, Rodrigo and Markram, Henry and London, Michael and Segev, Idan},
title = {Neuron Geometry Underlies a Universal Local Architecture in Neuronal Networks},
year = {2019},
doi = {10.1101/656058},
journal = {bioRxiv}
}



.png)