find_induced_nodes

find_induced_nodes#

graph_tool.structure.find_induced_nodes(g, s, t, treewidth_bound=None)[git][source]#

Return the vertices on induced paths between two vertices of a chordal graph.

Parameters:
gGraph

Chordal graph to be used. Edge directions are ignored.

sVertex or int

First vertex.

tVertex or int

Second vertex.

treewidth_boundint (optional, default: None)

If given, a ValueError is raised as soon as the treewidth of the intermediate graphs exceeds this value.

Returns:
nodesnumpy.ndarray

The vertices on induced paths between s and t, including them, or an empty array if there are none besides the edge between them.

See also

is_chordal

Test for chordal graphs

all_paths

All simple paths between two vertices

Notes

An induced path is a path without chords, i.e. no edge of the graph joins two of its vertices that are not consecutive along it. The method of Elidan and Gould [elidan-learning-2008] adds the edge \((s, t)\) and repeatedly finds, with maximum cardinality search from \(s\), a triple \((u, v, w)\) of vertices that breaks chordality (with \(u\) and \(w\) adjacent to \(v\) but not to each other), which is added to the result and joined to \(s\). It is used to learn bounded-treewidth graphical models. A ValueError is raised if the graph is not chordal.

References

[elidan-learning-2008]

Gal Elidan and Stephen Gould, “Learning bounded treewidth Bayesian networks”, Journal of Machine Learning Research 9, 2699-2731 (2008), https://jmlr.org/papers/v9/elidan08a.html

Examples

>>> g = gt.Graph([(i, i + 1) for i in range(9)], directed=False)
>>> print(gt.find_induced_nodes(g, 1, 9, treewidth_bound=2))
[1 2 3 4 5 6 7 8 9]