loadGraph

pyagrum.loadGraph(filename)

Read a graph from a file, its format being given by its extension: .jgum (GUM, text), .bgum (GUM, binary) or .pkl (pickle).

Parameters:

filename (str) – the name of the file (see pyagrum.availableGraphExts())

Returns:

the graph, of the class written in the file

Return type:

pyagrum.DiGraph or pyagrum.DAG or pyagrum.UndiGraph or pyagrum.MixedGraph or pyagrum.PDAG or pyagrum.ChainGraph or pyagrum.MarkedGraph or pyagrum.PAG or pyagrum.CPDAG or pyagrum.MPDAG or pyagrum.MAG or pyagrum.EssentialGraph

Raises:

Example

import pyagrum as gum

gum.saveGraph(gum.fastPDAG("A->B-C"), "graph.jgum")
g = gum.loadGraph("graph.jgum")
type(g).__name__
# 'PDAG'
sorted(g.arcs()), sorted(g.edges())
# ([(0, 1)], [(1, 2)])