Loading and Visualizing Killwebs

This tutorial demonstrates how to use MIMIK to load and visualize killwebs.

[1]:
# import modules
import os
import json
%matplotlib widget

from mimik.killweb import Killweb

Loading from json file

A MIMIK killweb can be loaded from a JSON configuration file. A example of simple killweb configuration file is displayed below.

The first keyword defines the name of the killweb - simple_killweb. At the second level, each keyword defines a component of the system - Find1, Fix1, Track1, Find2, Fix2, Track2. A connected_component keyword is defined for each component and indicates the outgoing edges of the killweb graph. Attributes can be added to the component using the attributes keyword. In this example, the attribute is the position of each node defined by x and y.

[2]:
# config filename
config_filename = "simple_killweb.json"
configs_pth = os.path.join('configs', config_filename)

with open(configs_pth, 'r') as f:
        killweb_configs = json.load(f)
print(json.dumps(killweb_configs, indent=4))
{
    "simple_killweb": {
        "Find1": {
            "connected_components": [
                "Fix1",
                "Fix2"
            ],
            "attributes": {
                "x": 0,
                "y": 0
            }
        },
        "Fix1": {
            "connected_components": [
                "Track1",
                "Track2"
            ],
            "attributes": {
                "x": 1,
                "y": 0
            }
        },
        "Track1": {
            "connected_components": [],
            "attributes": {
                "x": 2,
                "y": 0
            }
        },
        "Find2": {
            "connected_components": [
                "Fix1",
                "Fix2"
            ],
            "attributes": {
                "x": 0,
                "y": 1
            }
        },
        "Fix2": {
            "connected_components": [
                "Track1",
                "Track2"
            ],
            "attributes": {
                "x": 1,
                "y": 1
            }
        },
        "Track2": {
            "connected_components": [],
            "attributes": {
                "x": 2,
                "y": 1
            }
        }
    }
}

The cell below initializes the MIMIK killweb class. The first arguement is the working directory that contains the configs directory (more directories will be added in later tutorials). The second argument is the path to the configs file. The third arguement is optional and puts the killweb class in silent mode, which suppressess some warnings.

[3]:
killweb = Killweb(working_dir=os.getcwd(), config_file=configs_pth, silent=True)

The killweb is visualized below.

[4]:
killweb.create_component_networkx_visualization();