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#

to_networkx(graph)

Convert ProblemGraph to NetworkX DiGraph.

export_graphml(graph, output_path)

Export NetworkX graph to GraphML format.

export_json(graph, output_path)

Export NetworkX graph to JSON format.

plot_hierarchy(graph, output_path[, figsize, dpi])

Generate static image of hierarchy using matplotlib.

analyze_hierarchy(graph)

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.

Parameters:
  • graph (networkx.DiGraph) – Graph to export

  • output_path (str) – Output file path (.graphml extension recommended)

Returns:

The output file path

Return type:

str

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.

Parameters:
  • graph (networkx.DiGraph) – Graph to export

  • output_path (str) – Output file path (.json extension recommended)

Returns:

The output file path

Return type:

str

paroto.viz.networkx_export.plot_hierarchy(graph, output_path, figsize=(12, 8), dpi=150)#

Generate static image of hierarchy using matplotlib.

Parameters:
  • graph (networkx.DiGraph) – Graph to plot

  • output_path (str) – Output file path (extension determines format: .png, .pdf, .svg)

  • figsize (tuple, optional) – Figure size in inches (width, height). Default: (12, 8)

  • dpi (int, optional) – Resolution for raster outputs. Default: 150

Returns:

The output file path

Return type:

str

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:

dict