Quick specification of graphs

Graphs can also be built with a fast dot-like syntax, similar to the one used for graphical models (see Quick specification of (randomly parameterized) graphical models) : '->' denotes a directed arc, '<-' a directed arc in the other direction, '-' an undirected edge, ';' separates independent chains. A name may be written between single quotes ('Visit Asia'->X, see Names between quotes); otherwise it contains neither space, '<' nor '>'.

pyagrum.fastDiGraph('A->B->C;B->E')
pyagrum.fastDiGraph('A->B<-C')       # both A and C point to B
pyagrum.fastUndiGraph('A-B-C')
pyagrum.fastMixedGraph('A->B-C')
pyagrum.fastDAG('A->B->C')
pyagrum.fastPDAG('A->B-C')
pyagrum.fastChainGraph('A->B-C')
pyagrum.fastMarkedGraph('A->B;B<->C;C o-> D;D o-o E;E-F')
pyagrum.fastPAG('X o-o Y;Y o-> Z')
pyagrum.fastPAG("'X'o-o'Y'")         # a circle may touch a quoted name
pyagrum.fastGraph('A->B-C')          # the type is chosen from the description (here a PDAG)

Note

A single '-' (not '--') is used for edges on purpose : pyagrum.fastMRF() already uses '--' to list the variables of a single factor (a clique), a different construct from a chain of pairwise edges. Writing 'A--B' in these functions raises an error rather than being silently misread.

fastGraph()

Build a graph from a dot-like syntax such as 'A->B->C;B-D<-E;', picking a concrete graph type from the syntaxes for which desc is valid (see pyagrum.checkFastSyntax).

fastDiGraph()

Build a graph from a dot-like syntax : 'A->B->C;B->E'.

fastUndiGraph()

Build a graph from a dot-like syntax : 'A->B->C;B->E'.

fastMixedGraph()

Build a graph from a dot-like syntax : 'A->B->C;B->E'.

fastDAG()

Build a graph from a dot-like syntax : 'A->B->C;B->E'.

fastPDAG()

Build a graph from a dot-like syntax : 'A->B->C;B->E'.

fastChainGraph()

Build a graph from a dot-like syntax : 'A->B->C;B->E'.

fastMarkedGraph()

Create a marked graph (pyagrum.MarkedGraph, or pyagrum.PAG for fastPAG) from a dot-like description.

fastPAG()

Create a marked graph (pyagrum.MarkedGraph, or pyagrum.PAG for fastPAG) from a dot-like description.

See also this notebook for a tour of graph construction and algorithms.