Skip to content

abecker93/network-portrait-divergence

 
 

Repository files navigation

Network Portrait Divergence

Python code for computing portrait divergences, a simple, general-purpose tool for comparing networks.

Networks and their portraits

Please see the paper for more details:

An information-theoretic, all-scales approach to comparing networks
James P. Bagrow and Erik M. Bollt, 2018
arXiv:1804.03665

Table of Contents

Usage

The output of each calculation is a float between 0 and 1 describing how similar the two networks are (0 = identical, 1 = maximally different, according to this measure).

Portrait divergences can be computed at the command line or within Python scripts:

Command line

  1. Basic example:
    python portrait_divergence.py data/net1.edgelist data/net2.edgelist

  2. Networks stored in GraphML files:
    python portrait_divergence.py -graphml digraph_time1.graphml digraph_time2.graphml

  3. Use faster C++ code (assuming it's installed):
    python portrait_divergence.py --cpp big_g.edgelist big_h.edgelist

  4. Let's get crazy:
    python portrait_divergence.py --weighted=strength -b 10 --graphml g.graphml h.graphml

The code supports directed and weighted networks.

See the help string for more: python portrait_divergence.py -h

Python

Here's a script to compare Erdős-Rényi and Barabási-Albert graphs:

import networkx as nx
from portrait_divergence import portrait_divergence

Ger1  = nx.erdos_renyi_graph(100, 3/99)
Ger2  = nx.erdos_renyi_graph(100, 3/99)
Gba1 = nx.barabasi_albert_graph(100, 3)
Gba2 = nx.barabasi_albert_graph(100, 3)

print("Djs(ER1,ER2) =", portrait_divergence(Ger1, Ger2))
print("Djs(ER1,BA1) =", portrait_divergence(Ger1, Gba1))
print("Djs(ER1,BA2) =", portrait_divergence(Ger1, Gba2))
print("Djs(BA1,BA2) =", portrait_divergence(Gba1, Gba2))

Result:

Djs(ER1,ER2) = 0.139438811433
Djs(ER1,BA1) = 0.831004770397
Djs(ER1,BA2) = 0.864124658944
Djs(BA1,BA2) = 0.214176902159

Requirements

A recent install of Anaconda Python should come with everything you need.

Citation

If you use Portrait Divergence, please cite our paper:

James P. Bagrow and Erik M. Bollt, An information-theoretic, all-scales approach to comparing networks (2018) arXiv:1804.03665

Here is a bibtex key:

@article{bagrow2018information,
  title={An information-theoretic, all-scales approach to comparing networks},
  author={Bagrow, James P and Bollt, Erik M},
  journal={arXiv preprint arXiv:1804.03665},
  year={2018}
}

See also:

Portraits of Complex Networks — the original paper and idea behind Portrait Divergence.

About

An information-theoretic, all-scales approach to comparing networks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 69.7%
  • C++ 29.9%
  • Makefile 0.4%