paroto.viz.networkx_export#
NetworkX graph export utilities for hierarchy visualization.
This module provides functions to export parameter hierarchies as NetworkX graphs, enabling analysis with graph algorithms and export to various formats for external tools.
Functions#
|
Convert ProblemGraph to NetworkX DiGraph. |
|
Export NetworkX graph to GraphML format. |
|
Export NetworkX graph to JSON format. |
|
Generate static image of hierarchy using matplotlib. |
|
Analyze hierarchy structure and return statistics. |
Module Contents#
- paroto.viz.networkx_export.to_networkx(graph)#
Convert ProblemGraph to NetworkX DiGraph.
- Parameters:
graph (
ProblemGraph) – Problem graph from extract_hierarchy()- Returns:
Directed graph with node attributes: - ‘level’: hierarchy level (int) - ‘type’: node type (str) - ‘units’: variable units (str) - ‘value’: variable value - ‘label’: simplified display name
- Return type:
networkx.DiGraph
- paroto.viz.networkx_export.export_graphml(graph, output_path)#
Export NetworkX graph to GraphML format.
GraphML is supported by tools like yEd, Gephi, and Cytoscape.
- paroto.viz.networkx_export.export_json(graph, output_path)#
Export NetworkX graph to JSON format.
Exports in node-link format compatible with D3.js and other JavaScript libraries.
- paroto.viz.networkx_export.plot_hierarchy(graph, output_path, figsize=(12, 8), dpi=150)#
Generate static image of hierarchy using matplotlib.
- Parameters:
- Returns:
The output file path
- Return type:
- paroto.viz.networkx_export.analyze_hierarchy(graph)#
Analyze hierarchy structure and return statistics.
- Parameters:
graph (
networkx.DiGraph) – Graph to analyze- Returns:
Statistics including: - ‘num_nodes’: total number of nodes - ‘num_edges’: total number of edges - ‘num_levels’: number of hierarchy levels - ‘nodes_by_level’: dict mapping level -> count - ‘nodes_by_type’: dict mapping type -> count - ‘max_in_degree’: maximum number of inputs to a node - ‘max_out_degree’: maximum number of outputs from a node
- Return type: