pymnet.MultilayerNetwork

class pymnet.MultilayerNetwork(aspects=0, noEdge=0, directed=False, fullyInterconnected=True)

General multilayer network with a tensor-like interface.

See Reference [1] for background on the definition of this class.

There are several ways of accessing the edges and nodes of the network. If there is a single aspect, then the following notation can be used:

>>> net[i,s]                   #node i at layer s
>>> net[i,j,s,r]               #edge between nodes i and j and layers s and r
>>> net[i,j,s] == net[i,j,s,s] #edge between nodes i and j at layer s

Following slicing notation can also be used:

>>> net[i,:,s,:] == net[i,s]   #node i at layer s
>>> net[i,j,s,:]               #node i at layer s, but only links to j are visible
>>> net[i,:,s,r]               #node i at layer s, but only links to layer r are visible
>>> net[i,:,s] == net[i,:,s,s]

Similar notation holds for two (or more) aspects:

>>> net[i,s,x]                 #node i at layer s in aspect 1 and at layer x in aspect 2
>>> net[i,j,s,x]               #link i,j at layer s in aspect 1 and layer x in aspect 2 = i,j,s,s,x,x
>>> net[i,j,s,r,x,y]           #link i,j between layers s and r in aspect 1 and between layers x and y in aspect 2
>>> net[i,:,s,:,x,:] == net[i,s,x]
>>> net[i,j,s,:,x,y]           #node i at layer s and y, but only links to j and y are visible
>>> net[i,:,s,x] == net[i,:,s,s,x,x]
Parameters:
aspectsint

Number of aspects

noEdgeobject

Any object signifying that there is no edge.

directedbool

True if the network is directed, otherwise it’s undirected.

fullyInterconnectedbool

Determines if the network is fully interconnected, i.e. all nodes are shared between all layers. Ignored if aspects==0.

See also

MultiplexNetwork

A class for multiplex networks

Notes

The default data structure behind this class is a graph similar to the one described in Reference [1] implemented with nested dictionaries. The downside to this implementation is that, for example, iterating through all the inter-layer links is not possible without inspecting also the inter-layer links.

References

[1] Multilayer Networks. Mikko Kivela, Alexandre Arenas, Marc Barthelemy, James P. Gleeson, Yamir Moreno, Mason A. Porter, arXiv:1309.7233 [physics.soc-ph]

Attributes:
edges

Methods

add_layer(layer[, aspect])

Adds an empty layer to the network.

add_node(node[, layer])

Adds an empty node to the network.

get_layers([aspect])

Return the set of (elementary) layers (in a given aspect).

get_supra_adjacency_matrix([includeCouplings])

Return the supra-adjacency matrix and a list of node-layer pairs.

iter_layers([aspect])

Iterate over all layers.

iter_node_layers()

Iterate over all node-layer pairs.

iter_nodes([layer])

Iterate over nodes in the network.

__init__(aspects=0, noEdge=0, directed=False, fullyInterconnected=True)

Methods

__init__([aspects, noEdge, directed, ...])

add_layer(layer[, aspect])

Adds an empty layer to the network.

add_node(node[, layer])

Adds an empty node to the network.

get_layers([aspect])

Return the set of (elementary) layers (in a given aspect).

get_supra_adjacency_matrix([includeCouplings])

Return the supra-adjacency matrix and a list of node-layer pairs.

iter_layers([aspect])

Iterate over all layers.

iter_node_layers()

Iterate over all node-layer pairs.

iter_nodes([layer])

Iterate over nodes in the network.

Attributes

edges