Skip to content

yohm/network_analysis

Repository files navigation

Network Analysis

A program to conduct a typical network analysis. By giving a data of undirected weighted network, you will get

  • basic network statistics
    • number of nodes
    • number of edges
    • average degree
    • clustering coefficient
    • average edge weight
    • average overlap
  • P(k): degree distribution
  • P(w): edge weight distribution
  • P(s): node strength distribution
  • C(k): clustering spectrum (local clustering coefficient as a function of degree)
  • s(k): node strength as a function of degree
  • k_{nn}(k): average degree of neighbors of nodes having degree k (assortativity)
  • O(w): link overlap as a function of link weight
  • link removal percolation analysis
  • Community detection using infomap

Input format

Network should be given by a text file, where each row indicates a link. Each row consists of three columns. The first two columns indicate the node ids while the last column denotes the link weight. So the input file looks like the following.

0 3 38
0 4 796
1 2 1
1 7 34
2 4 34
5 6 1
...

You can find a sample input file sample/net.edg in this repository.

Usage

Compiling

After you clone the repository, update submodule as well.

git submodule update --init --recursive

Run make to compile the program. Specify CXX if necessary.

env CXX=g++ make

You will find analyzer.out. Since the makefile is very simple, you can edit it by yourself if you encountered a trouble.

The code is parallelized OpenMP as well. If you have a compiler supporting OpenMP, you can enable OpenMP by specifying -fopenmp option. For example,

env CXX=g++-5 OPT='-O2 -fopenmp -std=c++11' make

Also make infomap.

cd infomap && make && make lib && make python

To build python, swig is required. If not installed, run

brew install swig

In addition to these, it is also required to install dependent packages:

pipenv install

Running

Just run run.sh specifing the network file and output directory as arguments.

./run.sh net.edg ./out

Then you'll find the output files in the current directory. If you specify the second argument, output files are generated in that directory.

Plotting

We prepared scripts to make plots. Python3, numpy, matplotlib are rquired.

./plot/plot_all.sh <result directory> [figure directory]

The first argument specifies the output directory. Please specify the directories where the result files are generated. You can specify the directory where figure files are generated by the second argument. By default, figure directory is the current directory. For example, run

./plot/plot_all.sh ./out ./out

You'll find sample outputs in sample directory in this repository.

Calculating ensemble averages

If you have several network files, we can calculate ensemble average of network statistics. The procedure would be like the following.

./run.sh 1.edg ./1_out  # we calculate network properties for each network
./run.sh 2.edg ./2_out
./run.sh 3.edg ./3_out
./run.sh 4.edg ./4_out
...
./ensemble/run_averaging.sh '[1-9]_out' output  # This will calculate the ensemble average over all data files in the specified directories 

LICENSE

The MIT license except for the submodules. For licensing of the submodules, refer to README of each submoudle.

The MIT License (MIT)

Copyright (c) 2016,2017 Yohsuke Murase

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

conduct a typical network analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published