quemb.molbe.graphfrag.GraphGenUtility.export_graph¶
- static GraphGenUtility.export_graph(edge_list, adx_map, adjacency_graph, origin_per_frag, dnames, outdir=None, outname='AdjGraph', cmap='cubehelix', node_position='coordinates')¶
Export a visual representation of a fragment-based adjacency graph to a PNG.
This function draws a directed network graph using a provided adjacency structure, with fragments color-coded and displayed using either coordinate-based or spring-layout node positioning, and saves the resulting image to the specified output directory.
- Parameters:
edge_list (
list
[Sequence
]) – A list of edge groupings, each corresponding to a fragment’s set of directed edges.adx_map (
dict
) – Mapping from node indices to node metadata (must include ‘coord’ and ‘label’ keys).adjacency_graph (
Graph
) – The NetworkX graph containing node and edge connectivity.origin_per_frag (
list
[Sequence
[int
]]) – A list of node index groups, each corresponding to the origin nodes of a fragment.dnames (
list
[str
]) – Names for each fragment, used in the legend.outdir (
Path
|None
) – If specified as Path: export .png to outdir. If None: no .png is exported, but (fix, ax) are still returned.outname (
str
) – Filename (without extension) for the output image. Default is “AdjGraph”.cmap (
str
) – Matplotlib colormap name used to color-code fragments. Default is “cubehelix”.node_position (
str
) – Node positioning strategy: “coordinates” for z-shifted spatial coordinates, or “spring” for force-directed layout. Default is “coordinates”.
- Returns:
(fix, ax) – Returns the corresponding pyplot objects.
- Return type:
Notes
Assumes that adx_map contains a “coord” field for all nodes: [x, y, z] coordinates when using “coordinates” positioning.
Colors are assigned per fragment based on the chosen colormap.
Nodes are drawn in two layers to produce a bordered effect.
Arcs between nodes are radially offset to distinguish overlapping edges.