Network construction and manipulation

This section includes some basic information about the core multilayer data structure used in the py3plex library.

The multinet

The multinet class is the main data structure used. Its functionality can be described in three simple points:

  1. Network parsing

  2. Network conversion

  3. Network decomposition

Every time a new network is used, it needs to be packed into a simple object-line interface, as done below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from py3plex.core import multinet

# initialize the network object
multilayer_network = multinet.multi_layer_network()

# load the file
multilayer_network.load_network("imdb_gml.gml",directed=False,label_delimiter="---")

# compute some basic statistics
multilayer_network.basic_stats()

Network parsers

Network parsers lie at the core of every network library. As py3plex is build on top of NetworkX package, it supports all parsers present there, for example:

  • edgelist parsing (edgelist)

  • gpickle compressed network parsing (gpickle)

  • GML format (gml)

  • networkx objects (nx)

The user must simply take care of the input file ending, or in the case of a raw networkx file, simply pass it as input.

The input type is specified using the input_type flag when using the load_network method.

Working with multilayer networks

Having introduced some basic concepts, we continue with conventions, adopted to successfully work with multilayer networks.

  1. Each not and edge can have a type flag assigned.

  2. Each edge can have a weight.

  3. Target node class (if specified), must have the label flag, where the value is a string representing different delimiter-separated classes. For example: class1—class2—class3 represent a node with 3 classes assigned (multiclass-multilabel problem.

The label_delimiter is specified when inputting the network

1
load_network(input_file="example.gpickle", directed=False, input_type="gpickle",label_delimiter="---"):

Examples

Load a gml file:

1
multilayer_network.load_network(input_file="example.gml", directed=False, input_type="gml"):

Load a gpickle file:

1
multilayer_network.load_network(input_file="example.gpickle", directed=False, input_type="gpickle"):

Load a gpickle file, with one type of nodes labeled:

1
multilayer_network.load_network(input_file="example.gpickle", directed=False, input_type="gpickle",label_delimiter="---"):

etc.