MAG.saveGUM
- MAG.saveGUM(name, binary=None, indent=None)
Save the graph as a .jgum (text) or .bgum (binary) file (its class, its nodes with their names, its arcs, edges and marks).
- Parameters:
name (
str) – the name of the filebinary (
bool, optional) – True for the msgpack-based .bgum binary format, False for the JSON-based .jgum text format. By default, the format is given by the extension of name (binary for an unknown extension).indent (
int, optional) – JSON indentation for the .jgum text format (ignored for the binary format): -1 for the most compact output, N>=0 to pretty-print with N spaces. Defaults topyagrum.config["core","jgumIndent"].
- Raises:
pyagrum.InvalidArgument – if binary contradicts the extension (
.jgumor.bgum) of name- Return type:
None
Example
import pyagrum as gum
dag = gum.fastDAG("A->X;Y<-B;X<-T->Y")
mag = gum.MAG.fromDAG(dag, {4}) # T latent: A->X<->Y<-B
mag.saveGUM("mag.jgum")
print(gum.loadGraph("mag.jgum"))
# {0<A>,1<X>,2<Y>,3<B>} , {0 --> 1, 2 <-- 3, 1 <-> 2}
Class