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:
- Returns:
- nodes
numpy.ndarray The vertices on induced paths between
sandt, including them, or an empty array if there are none besides the edge between them.
- nodes
See also
is_chordalTest for chordal graphs
all_pathsAll 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
ValueErroris 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]