fastMarkedGraph
- pyagrum.fastMarkedGraph(desc)
Create a marked graph (
pyagrum.MarkedGraph, orpyagrum.PAGforfastPAG) from a dot-like description.An edge is given by its two marks around a
'-':'<'or'>'for an arrowhead,'o'for a circle, nothing for a tail. A circle must be separated from the name of its node by a space ('C o-> D'; in'Co->D','Co'is a node). Without a node name on its side of the edge,'o'is a node:'o->B','A->o->B'and'A-o'use a node named'o'. A name may be quoted ("'Visit Asia' o-> X"), and a circle may touch a quoted name ("'A'o->'B'"). An edge may be repeated with the same marks ('A->B;A->B') but not with different ones ('A->B;B->A').- Raises:
pyagrum.InvalidArgument – If the description is malformed (e.g.
'A>-B'or'A o -B'), or if the nodes are ids and the largest one leaves more than max(number of nodes, 65536) absent ids below it ('0->2000000000').pyagrum.InvalidEdge – If the description describes an edge with different marks.
- Parameters:
desc (
str) – the string containing the dot-like specification- Return type:
Example
import pyagrum as gum
g = gum.fastMarkedGraph("A->B<->C;C o-o D")
print(g)
# {0<A>,1<B>,2<C>,3<D>} , {0 --> 1, 2 o-o 3, 1 <-> 2}
g = gum.fastMarkedGraph("'A'o->'B'") # a circle may touch a quoted name
print(g)
# {0<A>,1<B>} , {0 o-> 1}