Skip to main content

mulp

This repository/package includes a python script that implements the Multilayer PageRank algorithm presented in Bravo and Óskarsdóttir (2020) and Óskarsdóttir and Bravo (2021, ArXiV , Publisher).

Installation

pip install mulp

Input instructions

There are three primary input files:

  • Individual layer files (.ncol)
  • Common Nodes file (csv)
  • Personal Node file (csv)

Each layer in the multilayer network requires its own .ncol file with the appropriate ncol file format.

Example ncol layer file (.ncol):

CommonNodeA SpecificNodeA
CommonNodeB SpecificNodeA
CommonNodeC SpecificNodeB
CommonNodeD SpecificNodeC

The inter-layer connections are only allowed between common nodes as to follow the structure layed out by Óskarsdóttir & Bravo (2021):

Example input file(.csv):

CommonNode1
CommonNode2
CommonNode3

To construct the personal matrix one must specify the influence (or personal) nodes in the following format (example input .csv file):

InfluentialNode1
InfluentialNode2
InfluentialNode3

Usage

Multilayer Network Initialization

To create a Multilayer Network the following arguments are available:

layer_files (list): list of layer files

common_nodes_file (str): csv file to common nodes

personal_file (str): file to create personal matrix

bidirectional (bool, optional): wheter edges are biderectional or not. Defaults to False.

sparse (bool, optional): use sparse or dense matrix. Defaults to True.

from mulp import MultiLayerRanker
ranker = MultiLayerRanker(layer_files=['products.ncol','districts.ncol'],
                           common_nodes_file= './common.csv',
                           personal_file= './personal.csv' ,
                           bidirectional=True,
                           sparse = True)

The test directory on the project Github includes some other examples for non-directional or non-sparse matrices.

Ranking

The rank method of the MultiLayerRanker class runs the MultiLayer Personalized PageRank Algorithm. One can choose to run different experiments with varying alphas by specifying it in the method call:

alpha (int,optional): PageRank exploration parameter, defaults to .85

eigs = ranker.pageRank(alpha = .85)

This method returns the leading eigenvector corresponding to each node's rank.

Output Formatting

The formattedRanks method allows getting the rankings with appropriate node labels in a dictionary format: x

eigs (ndarray): corresponding eigenvector to format

ranker.formattedRanks(eigs)

The adjDF method allows getting a personal or adjacency matrix with corresponding labels as a dataframe:

matrix (ndarray) : an adj matrix or personal matrix to transform

f (str,optional): Optional, if true, writes the df to an output csv

#for persoanl matrix
personalDF = ranker.toDf(ranker.personal)
#for adj matrix
adjDf = ranker.toDf(ranker.matrix)

mulp Average Daily Downloads

Metadata

Release files for mulp 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mulp 1.1.1
File Size Uploaded Provenance Actions
mulp-1.1.1.tar.gz 17.6 kB Without provenance Details for mulp-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mulp 1.1.1
File Interpreter ABI Platform Actions
mulp-1.1.1-py3-none-any.whl Python 3 none any Details for mulp-1.1.1-py3-none-any.whl

Total release size: 35.4 kB

Release files / mulp-1.1.1.tar.gz

Download URL mulp-1.1.1.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3ba4659056d9bd2c37b0824c2fc39705e811b4586f246d060b54229d9c9e3034
BLAKE2b-256 checksum
How to use checksums
8109496329223c98faf5d71206fc7cd1e6ed99c9e521d10815d8a4c47f0f4b0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.5

Release files / mulp-1.1.1-py3-none-any.whl

Download URL mulp-1.1.1-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e907fbd6c35301ef281a6c66e7e6409d6710253d49feaecac8dd95f808d34563
BLAKE2b-256 checksum
How to use checksums
61217c26a62df48917ad5655fa2afbdb1bfaa9a5d8959bc5664d0109079166d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.5

Security for mulp 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page