Grouper.visualization.visualize_graph module
A module to visualize the graph structure of GroupGraph for seeing connectivity.
- Grouper.visualization.visualize_graph.calculate_port_positions(center_x, center_y, num_ports, distance_from_center, zoom_factor=0.4)
- Grouper.visualization.visualize_graph.generate_svg(num_ports, node_type, radius_node=50, radius_ports=30, distance_from_center=48, color='lightblue')
- Grouper.visualization.visualize_graph.generate_svg_for_node(num_ports, node_type, radius_node=50, radius_ports=10, distance_from_center=80, color='lightblue')
- Grouper.visualization.visualize_graph.nx_visualize(group_graph, layout=<function spring_layout>, **kwargs)
Draw on a networkx canvas the current GroupGraph structure.
- Parameters:
group_graph (genGrouper.GroupGraph) – The group graph to plot. Will size the canvas based on the size of the group graph. Labels will be placed on each node based on the “type” of the node.
layout (function, optional, default nx.spring_layout) – Function to apply to the group_graph in order to determine position of nodes on canvas.
kwargs (dict, optional, default None) – Extra parameters passed to layout function. Default kwargs are passed to nx.spring_layout.
- Returns:
fig – Drawn canvas of group_graph
- Return type:
matplotlib.pyplot.Figure
- Grouper.visualization.visualize_graph.spring_layout(group_graph, iterations=50, k=1.0)
Computes a spring layout for a generic graph.
- Parameters:
group_graph – The graph structure with nodes and edges
iterations – Number of iterations for layout optimization
k – Spring constant (controls node spacing)
- Returns:
A dictionary mapping nodes to 2D positions
- Return type:
pos
- Grouper.visualization.visualize_graph.visualize(group_graph, pos=None, ax=None)
Visualize a graph with optional custom positioning for nodes.
- Parameters:
group_graph (A NetworkX graph object to be visualized.)
pos (A dictionary specifying positions for nodes (optional).) – If None, a default layout will be used.
ax (matplotlib Axes (optional). If provided, draw into the given) – axes (used to compose with other panels — e.g., a side-by-side chemical structure view). If None, a new figure is created.
- Returns:
The figure containing the rendered port-graph.
- Return type:
matplotlib.figure.Figure
- Grouper.visualization.visualize_graph.visualize_cytoscape(group_graph, stylesheet=None, node_colors=None, debug=False)
Function to create a plotly dash application to visualize a graph.
- Parameters:
group_graph (-) – The graph object to be visualized.
stylesheet (-) – A dash cytoscape stylesheet. See https://dash.plotly.com/cytoscape/styling for more details.
colorList (-) – The colors to apply to each node. Colors are assigned based on the order of Groups in GroupGraph.nodes. The default stylesheet selects nodes based on Group.type name. Colorlist colors can be selected from Standard RGB and Hex colors are accepted, along with basic colors recognized by CSS. Note that by default edges are colored from the source node to target node colors.
debug (-) – App debugger to call when running the app.