API reference

andrey.viz.classify_edge#

andrey.viz.classify_edge(mark_i, mark_j, kind)[source]#

Name the edge type from its endpoint-mark pair and the graph kind.

The name selects the edge’s color and mark shapes: directed is the graphite backbone, and the rest carry the palette’s uncertainty colors.

Parameters:
  • mark_i (int) – The endpoint marks at nodes i and j: TAIL, ARROW, or CIRCLE from andrey.core.structure.

  • mark_j (int) – The endpoint marks at nodes i and j: TAIL, ARROW, or CIRCLE from andrey.core.structure.

  • kind (str) – The graph kind (dag / cpdag / pag / digraph). Only ARROW/ARROW reads differently across kinds.

Returns:

"directed" (->), "undirected" (--), "bidirected" (<-> outside a digraph), "twocycle" (<-> in a digraph: two directed edges), or "partial" (an edge with a circle end: o->, -o, or o-o).

Return type:

str

Raises:

ValueError – If a mark is not TAIL, ARROW, or CIRCLE, or kind is not one of the four kinds.

Notes

ARROW/ARROW is kind-relative: a bidirected edge (latent confounder) under a PAG, a twocycle (feedback, two directed edges) under a directed graph. The two are drawn differently on purpose, so a reader never mistakes feedback for a hidden common cause.

Examples

>>> from andrey.core.structure import ARROW, TAIL
>>> from andrey.viz import classify_edge
>>> classify_edge(TAIL, ARROW, "dag")
'directed'
>>> classify_edge(ARROW, ARROW, "pag"), classify_edge(ARROW, ARROW, "digraph")
('bidirected', 'twocycle')