Commit fc5f5251 authored by Jan Žižka's avatar Jan Žižka
Browse files

Add graph type to layer

This will be used to grow the network using appropriate algorithm.
parent ace34599
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
from pymnet import nx, MultilayerNetwork, draw
import random
import numpy as np
from enum import Enum, auto


# Ensure reproducibility by explicitly setting seed
@@ -8,11 +9,17 @@ random.seed(42)
np.random.seed(42)


class GraphType(Enum):
    BA = auto()
    ER = auto()


class Layer:

    def __init__(self, name, nxnet):
    def __init__(self, name, nxnet, graph_type):
        self.name = name
        self.nxnet = nxnet
        self.graph_type = graph_type

    def __repr__(self):
        return f"Layer({self.name})"
@@ -119,10 +126,10 @@ net = Network("A Software System")
# For demonstration use Barabasi-Albert and Erdos-Renyi models to reporesent
# each aspect model, for real systems the model is extracted from the system
# using empirical methods.
net.add_layer(Layer("Programmers", nx.barabasi_albert_graph(50, 1)), "blue")
net.add_layer(Layer("Git repositories", nx.barabasi_albert_graph(15, 1)), "orange")
net.add_layer(Layer("Programs", nx.erdos_renyi_graph(20, 0.3)), "magenta")
net.add_layer(Layer("Runtimes", nx.barabasi_albert_graph(4, 1)))
net.add_layer(Layer("Programmers", nx.barabasi_albert_graph(50, 1), GraphType.BA), "blue")
net.add_layer(Layer("Git repositories", nx.barabasi_albert_graph(15, 1), GraphType.BA), "orange")
net.add_layer(Layer("Programs", nx.erdos_renyi_graph(20, 0.3), GraphType.ER), "magenta")
net.add_layer(Layer("Runtimes", nx.barabasi_albert_graph(4, 1), GraphType.BA))


# Add inter layer relationships. For demonstration create links