discopt.decomposition.graph.export#
Serialize model-induced graphs to interchange formats.
The advisor’s export_graph surface (design doc §14) dumps a graph for
external tooling — graph databases, partitioners, and visualizers. Four formats
cover the immediate needs:
"json"— a node-link dict, easy to consume anywhere."dot"— Graphviz, for quick rendering."graphml"— for graph-analysis tools (Gephi, networkx, igraph)."metis"— the graph input format for the METIS/KaHyPar partitioners; feed it to an external partitioner to obtain a bordered-block-diagonal ordering, then re-import the result via the GCG-style.decreader (read_dec()).
Exports operate on the variable dependency graph (variable vertices, edges =
co-occurrence in a constraint), which is what partitioners consume. The bipartite
incidence is available via the bipartite flag for visualization.
.dec interchange (write_dec() / read_dec()) round-trips a resolved
decomposition to/from the format SCIP and GCG use, so an external partitioner or
GCG run can supply the block/border structure.
Functions#
|
Serialize graph's variable dependency graph to fmt. |
|
Write a GCG-style |
|
Read a GCG |
Module Contents#
- discopt.decomposition.graph.export.export_graph(graph: discopt.decomposition.graph.base.ModelGraph, fmt: str = 'json') str#
Serialize graph’s variable dependency graph to fmt.
- Parameters:
graph (ModelGraph) – The model-induced graph to export.
fmt (str) – One of
"json","dot","graphml","metis".
- Returns:
The serialized graph.
- Return type:
str
- discopt.decomposition.graph.export.write_dec(structure, model, path: str) None#
Write a GCG-style
.decfile for structure over model.Emits
NBLOCKS, oneBLOCK ksection listing that block’s constraint identifiers, and aMASTERCONSSsection for the coupling rows — the format SCIP/GCG read and write, so a discopt decomposition can be handed to (or taken from) that toolchain.
- discopt.decomposition.graph.export.read_dec(path: str, model) discopt.decomposition.structure.DecompositionStructure#
Read a GCG
.decfile and return aDecompositionStructure.The
MASTERCONSSbecome the coupling rows; blocks are recomputed from the non-coupling constraints (so the partition is always internally consistent with the model, regardless of how the file grouped them).