Multilayer network tensor factorization, for community detection, link prediction and measure layer interdependence.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cpp
data
python
.DS_Store
.gitignore
LICENSE
README.md

README.md

MultiTensor

Multilayer network tensor factorization, for community detection, link prediction and measure layer interdependence.

Implements the algorithm described in:

De Bacco, C., Power, E. A., Larremore, D. B., & Moore, C. (2017). Community detection, link prediction, and layer interdependence in multilayer networks. Physical Review E, 95(4), 042317.

If you use this code please cite this article.
A preprint version can be found here or here.

Copyright (c) 2016 Caterina De Bacco.

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.

What's included:

  • cpp : c++ version of the algorithm. Faster than the Python one.
  • python : Python version. Slower than c++.
  • data : Contains sample adjacency files to test the code.

Requirements:

Need to make a directory called data outside the cpp and python folders. To make one, just type from the command line, inside that folder:

  • mkdir data

Input format.

The multilayer adjacency matrix should be formatted as an edge list with L+3 columns:

E node1 node2 3 0 0 1

The first columns tells the algorithm that the row denotes an edge; the second and third are the source and target nodes of that edge, respectively; l+3 column tells if there is that edge in the l-th layer and the weigth (must be integer). In this example the edge node1 --> node2 exists in layer 1 with weight 3 and in layer 4 with weight 1, but not in layer 2 and 3.

Note: if the network is undirected, you only need to input each edge once. You then need to specificy to the algotihm that you are considering the undirected case: for the cpp version this is done by running ./MultiTensor_undirected (first you need to compile it by changing the Makefile accordingly); for the python version this is done by giving as a command line input parameter -u=1.

Output.

Three files will be generated inside the data folder: the two NxK membership matrices U and V, and the KxK layer affinity matrix W. Supposing that K=4 and E=".dat" the output files will be inside data folder with names:

  • u_K4.dat
  • v_K4.dat
  • w_K4.dat

The first line outputs the Max Likelihood among the realizations. For the membership files, the subsequent lines contain L+1 columns: the first one is the node label, the follwing ones are the (not normalized) membership vectors' entries. For the affinity matrix file, the subsequent lines start with the number of the layer and then the matrix for that layer. For the restricted assortative version only the diagonal entries of the affinity matrix are printed. The first entry of each row is the layer index.