Git Product home page Git Product logo

netrd's Introduction

PyPI version ReadTheDocs CI

netrd: A library for network {reconstruction, distances, dynamics}

This library provides a consistent, NetworkX-based interface to various utilities for graph distances, graph reconstruction from time series data, and simulated dynamics on networks.

Some resources that maybe of interest:

Installation

netrd is easy to install through pip:

pip install netrd

If you are thinking about contributing to netrd, you can install a development version by executing

git clone https://github.com/netsiphd/netrd
cd netrd
pip install .

Usage

Reconstructing a graph

example reconstruction

The basic usage of a graph reconstruction algorithm is as follows:

from netrd.reconstruction import CorrelationMatrix
import numpy as np
# 100 nodes, 1000 observations
TS = np.random.random((100, 1000))

reconstructor = CorrelationMatrix()
G = reconstructor.fit(TS, threshold_type='degree', avg_k=15)
# or alternately, G = reconstructor.results['graph']

Here, TS is an N x L numpy array consisting of L observations for each of N sensors. This constrains the graphs to have integer-valued nodes.

The results dict object, in addition to containing the graph object, may also contain objects created as a side effect of reconstructing the network, which may be useful for debugging or considering goodness of fit. What is returned will vary between reconstruction algorithms.

Many reconstruction algorithms create a dense matrix of weights and use additional parameters to describe how to create a sparse graph; the tutorial has more details on these parameters.

Distances between graphs

example distance

The basic usage of a distance algorithm is as follows:

from netrd.distance import QuantumJSD
import networkx as nx
G1 = nx.fast_gnp_random_graph(1000, .1)
G2 = nx.fast_gnp_random_graph(1000, .1)

dist_obj = QuantumJSD()
distance = dist_obj.dist(G1, G2)
# or alternatively: distance = dist_obj.results['dist']

Here, G1 and G2 are nx.Graph objects (or subclasses such as nx.DiGraph). The results dictionary holds the distance value, as well as any other values that were computed as a side effect.

Dynamics on graphs

example distance

The basic usage of a dynamics algorithm is as follows:

from netrd.dynamics import VoterModel
import networkx as nx
ground_truth = nx.karate_club_graph()

dynamics_model = VoterModel()
synthetic_TS = dynamics_model.simulate(ground_truth, 1000)
# this is the same structure as the input data to a reconstructor
# G = CorrelationMatrix().fit(synthetic_TS)

This produces a numpy array of time series data.

Contributing

Contributing guidelines can be found in CONTRIBUTING.md.

Publications

  • Hartle H., Klein B., McCabe S., Daniels A., St-Onge G., Murphy C., and Hébert-Dufresne L. (2020). Network comparison and the within-ensemble graph distance. Proc. R. Soc. A 20190744. doi: 10.1098/rspa.2019.0744.
    • recent work introducing a baseline measure for comparing graph distances

netrd's People

Contributors

sdmccabe avatar leotrs avatar tlarock avatar charlesmurphy1 avatar empiricalstateofmind avatar dsaffo avatar netsiphd avatar ajgates42 avatar chiahungyang avatar jessica-davis avatar ryanjgallagher avatar mattk7 avatar xgfs avatar keygoksmg avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.