Open tbody-cfs opened 2 months ago
This seems to be more of a visualisation challenge than a compute challenge. For instance, both of the following work, but the result is very difficult to understand
from importlib.resources import as_file, files
from cfspopcon import Algorithm
import yaml
with as_file(files("cfspopcon").joinpath("variables.yaml")) as filepath:
with open(filepath) as f:
variables_dict = yaml.safe_load(f)
from pyvis.network import Network
net = Network()
for var_key in variables_dict.keys():
net.add_node(var_key, color="blue")
for alg_key in Algorithm.instances.keys():
net.add_node(alg_key, color="red")
for alg_key, alg in Algorithm.instances.items():
for var_key in alg.input_keys:
net.add_edge(var_key, alg_key)
for var_key in alg.return_keys:
net.add_edge(alg_key, var_key)
net.save_graph("example.html")
import networkx as nx
from importlib.resources import as_file, files
from cfspopcon import Algorithm
import yaml
with as_file(files("cfspopcon").joinpath("variables.yaml")) as filepath:
with open(filepath) as f:
variables_dict = yaml.safe_load(f)
G = nx.DiGraph()
for var_key in variables_dict.keys():
G.add_node(var_key)
for alg_key in Algorithm.instances.keys():
G.add_node(alg_key)
for alg_key, alg in Algorithm.instances.items():
for var_key in alg.input_keys:
G.add_edge(var_key, alg_key)
for var_key in alg.return_keys:
G.add_edge(alg_key, var_key)
nx.draw(G)
There are a lot of drawing options available at https://networkx.org/documentation/stable/auto_examples/drawing/index.html. Someone could experiment with these
Might be a useful way of representing interdependencies of algorithms
https://wimyedema.medium.com/drawing-dags-5cadcb452115 https://wimyedema.github.io/dagviz/