DiGraph.saveGUM

DiGraph.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

g = gum.fastDiGraph("A->B->C")
g.saveGUM("graph.jgum")
g2 = gum.loadGraph("graph.jgum")
type(g2).__name__, sorted(g2.arcs())
# ('DiGraph', [(0, 1), (1, 2)])

Class

DiGraph

Overridden in

ChainGraph.saveGUM, DAG.saveGUM, MixedGraph.saveGUM, PDAG.saveGUM