In [1]:
from bigraph_viz import plot_bigraph
import copy
plot_settings = {
'remove_process_place_edges': True,
'port_labels': False
}
save_images = False
if save_images:
plot_settings.update({
'out_dir': 'out',
'dpi': '250'
})
In [2]:
help(plot_bigraph)
Help on function plot_bigraph in module bigraph_viz.visualize_types:
plot_bigraph(state, schema=None, core=None, out_dir=None, filename=None, file_format='png', show_compiled_state=True, **kwargs)
Create and render a bigraph visualization using Graphviz from a given state and optional schema.
Parameters:
state (dict): The simulation state.
schema (dict): Optional schema defining the structure of the state.
core (VisualizeTypes): Visualization engine.
out_dir (str): Directory to write output.
filename (str): Name of the output file.
file_format (str): Output format (e.g., 'png', 'svg').
**kwargs: Additional arguments for styling or traversal.
Returns:
graphviz.Digraph: Rendered graph object.
In [3]:
forest = {
'v0': {
'v1': {},
'v2': {
'v3': {}
},
},
'v4': {
'v5': {},
},
}
plot_bigraph(forest, **plot_settings, filename='forest')
Writing out/forest
Out[3]:
In [4]:
hypergraph = {
'e0': {
'wires': {
'e0.0': 'v0',
'e0.1': 'v1',
'e0.2': 'v4',
}
},
'e1': {
'wires': {
'e0.0': 'v3',
'e0.1': 'v1',
}
},
'e2': {
'wires': {
'e0.0': 'v3',
'e0.1': 'v4',
'e0.2': 'v5',
}
},
}
flat = {
'v0': {},
'v1': {},
'v2': {},
'v3': {},
'v4': {},
'v5': {},
}
flat.update(hypergraph)
node_groups = [
[('v1',), ('e0',), ('v4',)],
[('e1',), ('v5',)],
[('v3',), ('e2',)],
]
plot_bigraph(flat, node_groups=node_groups, **plot_settings, filename='process_hypergraph')
Writing out/process_hypergraph
Out[4]:
In [5]:
plot_bigraph(flat, **plot_settings, collapse_processes=True, node_groups=node_groups, filename='hypergraph')
Writing out/hypergraph
Out[5]:
In [6]:
bigraph = {
'v0': {
'v1': {},
'v2': {
'v3': {}
},
},
'v4': {
'v5': {},
},
'e0': {
'wires': {
'e0.0': 'v0',
'e0.1': ('v0', 'v1'),
'e0.2': 'v4',
}
},
'e1': {
'wires': {
'e0.0': ('v0', 'v2', 'v3'),
'e0.1': ('v0', 'v1'),
}
},
'e2': {
'wires': {
'e0.0': ('v0', 'v2', 'v3'),
'e0.1': 'v4',
'e0.2': ('v4', 'v5'),
}
},
}
plot_bigraph(bigraph, **plot_settings, filename='process_bigraph')
Writing out/process_bigraph
Out[6]:
In [7]:
node_groups2 = [
[('v0', 'v1',), ('e0',), ('v0', 'v2',), ('e2',), ('v4', 'v5',), ],
[('e1',), ('v0', 'v2', 'v3'),],
]
plot_bigraph(bigraph, node_groups=node_groups2, **plot_settings, collapse_processes=True, filename='bigraph')
Writing out/bigraph
Out[7]:
In [ ]: