paroto.viz.networkx_export ========================== .. py:module:: paroto.viz.networkx_export .. autoapi-nested-parse:: 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 --------- .. autoapisummary:: paroto.viz.networkx_export.to_networkx paroto.viz.networkx_export.export_graphml paroto.viz.networkx_export.export_json paroto.viz.networkx_export.plot_hierarchy paroto.viz.networkx_export.analyze_hierarchy Module Contents --------------- .. py:function:: to_networkx(graph) Convert ProblemGraph to NetworkX DiGraph. :param graph: Problem graph from extract_hierarchy() :type graph: :py:class:`ProblemGraph` :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 :rtype: :py:class:`networkx.DiGraph` .. py:function:: export_graphml(graph, output_path) Export NetworkX graph to GraphML format. GraphML is supported by tools like yEd, Gephi, and Cytoscape. :param graph: Graph to export :type graph: :py:class:`networkx.DiGraph` :param output_path: Output file path (.graphml extension recommended) :type output_path: :py:class:`str` :returns: The output file path :rtype: :py:class:`str` .. py:function:: export_json(graph, output_path) Export NetworkX graph to JSON format. Exports in node-link format compatible with D3.js and other JavaScript libraries. :param graph: Graph to export :type graph: :py:class:`networkx.DiGraph` :param output_path: Output file path (.json extension recommended) :type output_path: :py:class:`str` :returns: The output file path :rtype: :py:class:`str` .. py:function:: plot_hierarchy(graph, output_path, figsize=(12, 8), dpi=150) Generate static image of hierarchy using matplotlib. :param graph: Graph to plot :type graph: :py:class:`networkx.DiGraph` :param output_path: Output file path (extension determines format: .png, .pdf, .svg) :type output_path: :py:class:`str` :param figsize: Figure size in inches (width, height). Default: (12, 8) :type figsize: :py:class:`tuple`, *optional* :param dpi: Resolution for raster outputs. Default: 150 :type dpi: :py:class:`int`, *optional* :returns: The output file path :rtype: :py:class:`str` .. py:function:: analyze_hierarchy(graph) Analyze hierarchy structure and return statistics. :param graph: Graph to analyze :type graph: :py:class:`networkx.DiGraph` :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 :rtype: :py:class:`dict`