EssentialGraph.saveGUM

EssentialGraph.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 file

  • binary (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 to pyagrum.config["core","jgumIndent"].

Raises:

pyagrum.InvalidArgument – if binary contradicts the extension (.jgum or .bgum) of name

Return type:

None

Example

import pyagrum as gum

eg = gum.EssentialGraph(gum.fastBN("A->B<-C"))
eg.saveGUM("eg.jgum")
g = gum.loadGraph("eg.jgum")
type(g).__name__, sorted(g.arcs())
# ('EssentialGraph', [(0, 1), (2, 1)])

Class

EssentialGraph