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.
Build a graph from a dot-like syntax such as |
|
Build a graph from a dot-like syntax : |
|
Build a graph from a dot-like syntax : |
|
Build a graph from a dot-like syntax : |
|
Build a graph from a dot-like syntax : |
|
Build a graph from a dot-like syntax : |
|
Build a graph from a dot-like syntax : |
|
Create a marked graph ( |
|
Create a marked graph ( |
See also this notebook for a tour of graph construction and algorithms.