MixedGraph.chainComponents

MixedGraph.chainComponents()

Return the chain components of the graph.

Each node is mapped to the index of its component: 0, 1, …, (number of components - 1), numbered in the order in which the components are found.

Returns:

mapping node id → index of its component

Return type:

dict[int, int]

Example

import pyagrum as gum

g = gum.fastMixedGraph("A->B-C;C->D-E")
cc = g.chainComponents()  # node id -> chain component
cc[1] == cc[2], cc[3] == cc[4], cc[0] == cc[1], cc[2] == cc[3]
# (True, True, False, False)

Used by

MixedGraph, ChainGraph, PDAG

Inheritance diagram of pyagrum.MixedGraph, pyagrum.ChainGraph, pyagrum.PDAG