import networkx as nx
import yaml
from pathlib import Path
import matplotlib as plt

file = Path('omni4d.core.yaml').open('r')
model = yaml.load(file)
graph = nx.Graph()

for sign, attributes in model.items():
    graph.add_node(sign, type=attributes['type'])
    if attributes['type'] in [
        'whole_part_tuple',
        'class_member_tuple',
        'ordinary_tuple'
    ]:
        for object, details in attributes['objects'].items():
            graph.add_edge(sign, object, role=details['role'])


# print(graph.nodes(data=True))
# print(graph.edges(data=True))
nx.write_graphml(graph, 'omni4d.core.graphml')

@@ -55,33 +55,8 @@
 Path
-%0Aimport matplotlib as plt
 %0A%0Afi
@@ -480,72 +480,8 @@
 )%0A%0A%0A
-# print(graph.nodes(data=True))%0A# print(graph.edges(data=True))%0A
 nx.w

Tidy up script