mbdlyb.io
Functions for exporting MBD models to various graph formats.
Supports exporting MBD networks to NetworkX graphs and yEd graph editor formats, with optional node type filtering and color customization.
Functions
|
Export an MBD network to a NetworkX directed graph. |
|
Export an MBD network to yEd graph editor format. |
Module Contents
- mbdlyb.io.export_to_nx(net: mbdlyb.MBDNet, *node_types: Type[mbdlyb.MBDNode], relation_types: list[Type[mbdlyb.MBDRelation]] | None = None, colormap: mbdlyb.colormap.ColorMap | None = None) networkx.DiGraph
Export an MBD network to a NetworkX directed graph.
Converts an MBD network structure to a NetworkX DiGraph, optionally filtering by node and relation types. The resulting graph can be used for analysis, visualization, or further processing.
- Parameters:
net (MBDNet) – The network to export.
*node_types (Type[MBDNode]) – Node types to include. If empty, includes all MBDNode types.
relation_types (list[Type[MBDRelation]]) – Relation types to include. If None, includes only MBDDependencies.
colormap (ColorMap) – Custom color mapping for nodes and relations. Uses default if None.
- Returns:
- NetworkX directed graph with nodes and edges representing the MBD structure.
Each node has ‘fqn’, ‘label’, and ‘color’ attributes. Each edge has ‘label’ and ‘color’ attributes.
- Return type:
nx.DiGraph
- mbdlyb.io.export_to_yed(net: mbdlyb.MBDNet, *node_types: Type[mbdlyb.MBDNode], group: pyyed.Group | None = None, is_graph_root: bool = True, colormap: mbdlyb.colormap.ColorMap | None = None) pyyed.Graph | pyyed.Group
Export an MBD network to yEd graph editor format.
Converts an MBD network to a yEd-compatible graph structure for visualization and editing in yEd. Hierarchical subnets are represented as groups, and dependencies and influences are shown as edges.
- Parameters:
net (MBDNet) – The network to export.
*node_types (Type[MBDNode]) – Node types to include. If empty, includes all MBDNode types.
group (yed.Group) – Parent group for nested export. Omit for root export.
is_graph_root (bool) – Whether this is the root export call. Default is True.
colormap (ColorMap) – Custom color mapping for elements. Uses default if None.
- Returns:
- yEd graph or group structure ready for serialization
and editing in the yEd graph editor.
- Return type:
yed.Graph | yed.Group