Use NetworkX python package to visualise the graphs and the solutions#
To use one of the described component here, you have to import them from khloraascaf_utils.to_networkx.
Constants#
Graph relation type#
- RELATION_ATTR = 'relation'#
Relation attribute name on edges.
Its value can be
EDGE_ATTRVAL,INVF_ATTRVALorDIRF_ATTRVAL.
- EDGE_ATTRVAL = 'edge'#
Property that assumes the edge is an edge in MDCG.
- INVF_ATTRVAL = 'inverted_fragment'#
Property that assumes the edge is an inverted fragment in MDCG.
- DIRF_ATTRVAL = 'direct_fragment'#
Property that assumes the edge is a direct fragment in MDCG.
For the solutions#
- SOLUTION_PATH_PREFIX_ATTR = 'solution_path'#
Prefix to write the solution path on the edges.
- SOLUTION_INVF_PREFIX_ATTR = 'solution_invf'#
Prefix to write the solution inverted fragments.
- SOLUTION_DIRF_PREFIX_ATTR = 'solution_dirf'#
Prefix to write the solution direct fragments.
For file extension#
- GRAPHML_EXT = 'graphml'#
GraphML file extension.
Functions#
Main function#
- mdcg_to_nxdigraph(mdcg, id_container)#
Format mdcg graph to a networkx digraph.
- Parameters:
mdcg (
MDCGraph) – Multiplied doubled contig graphid_container (
MDCGraphIDContainer) – Identifiers container
- Returns:
NetworkX graph
- Return type:
To add different solutions’ attributes#
- add_solution_path_in_nxdigraph(nxgraph, vertex_path, attribute_suffix)#
Add the solutions’ path to the networkx graph.
- add_solution_invf_in_nxdigraph(nxgraph, sol_invf, attribute_suffix)#
Add the solutions’ inverted fragments to the networkx graph.
To format the attribute keys according to the instance’s name#
- solution_path_attr(attribute_suffix)#
Format the attribute name for the solution’s path.
- solution_invf_attr(attribute_suffix)#
Format the attribute name for the solution’s inverted fragments.