Skip to content

Instantly share code, notes, and snippets.

@leriomaggio
Last active August 31, 2018 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leriomaggio/9b9f1695efd28208df90d6c0b595ae5a to your computer and use it in GitHub Desktop.
Save leriomaggio/9b9f1695efd28208df90d6c0b595ae5a to your computer and use it in GitHub Desktop.
NetworkX Tutorial @ MSCX - Setup Instructions

Network Analysis Tutorial using Python & networkx

MSCX Ph.D. Summer School, Salina (ME) - Italy

Author: Valerio Maggio

PostDoc Data Scientist @ FBK/MPBA

Contacts:

@leriomaggio vmaggio_at_fbk_dot_eu

Requirements

This tutorial will use Python 3

This tutorial requires the following packages:

  • Python version 3.6

    • Python 3.4+ should be fine as well
    • likely Python 2.7 would be also fine, but who knows? :P
  • matplotlib==2.2.3

  • networkx==2.1

  • pandas==0.23.0

  • hiveplot==2017.10.17.21.7

  • nxviz==0.5.0

  • numpy==1.14.3

  • jupyter==1.0.0

  • scipy==1.1.0

  • python-louvain==0.11

Easiest way: Anaconda Distribution of Python

If you have the Anaconda distribution of Python 3 installed on a Unix-like machine (Linux, macOS, etc.), then run make conda, which wraps the commands below.

  1. $ conda env create -f environment.yml
  2. $ source activate nams
  3. $ python checkenv.py

If you do not have the Anaconda distribution, I would highly recommend getting it for Windows, Mac or Linux. It provides an isolated Python computing environment that will not interfere with your system Python installation, and comes with a very awesome package manager (conda) that makes installation of new packages a single conda install pkgname away.

Alternative to Anaconda: pip install

For those who do not have the capability of installing the Anaconda Python 3 distribution on their computers, please follow the instructions below.

Run make venv, which wraps up the commands below.

  1. Create a virtual environment for this tutorial, so that the installed packages do not mess with your regular Python environment.
  2. $ pip install virtualenv
  3. $ virtualenv mscx
  4. $ source mscx/bin/activate
  5. $ pip install matplotlib networkx pandas hiveplot numpy jupyter

Check your environment:

Open a Terminal, and import the required packages:

$ pythoh

>>> import numpy as np
>>> import scipy as sp
>>> import networkx as nx
>>> import matplotlib.pyplot as plt
>>> import community
...

Just to name a few.... :)

Dataset References

  1. Divvy Data Challenge
  2. Konect Network Analysis Datasets

Resources

  1. Jon Charest's use of Circos plots to visualize networks of Metal music genres. [blog post][5] | [notebook][6]
  2. Gain further practice by taking this course online at DataCamp!
  3. A gentle introduction to graph theory on Vaidehi Joshi's website
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment