junction_tree

Contents

junction_tree#

graph_tool.structure.junction_tree(g)[git][source]#

Return a junction tree of a graph.

Parameters:
gGraph

Undirected graph, or directed acyclic graph (a Bayesian network).

Returns:
tGraph

Undirected tree (or forest) with one vertex per maximal clique of the triangulated graph.

cliquesVertexPropertyMap

Vector-valued property map with the vertices of g in every clique.

separatorsEdgePropertyMap

Vector-valued property map with the intersection of the cliques at the endpoints of every edge.

See also

treewidth

Upper bound on the treewidth

chordal_completion

Minimal chordal completion

chordal_cliques

Maximal cliques of a chordal graph

graph_tool.generation.moral_graph

Moral graph of a directed acyclic graph

Notes

A junction tree [lauritzen-local-1988] is a tree of the maximal cliques of a chordal graph such that the cliques containing any given vertex form a connected subtree. It is obtained as follows: 1. a directed graph is moralized (see moral_graph()); 2. the graph is made chordal with a minimal completion (see chordal_completion()); 3. its maximal cliques are found (see chordal_cliques()); and 4. a maximum spanning tree of the cliques is taken, with the size of their intersections as weights [jensen-optimal-1994]. The width of the decomposition is the size of the largest clique minus one.

References

[jensen-optimal-1994]

Finn V. Jensen and Frank Jensen, “Optimal junction trees”, Proceedings of the Tenth Conference on Uncertainty in Artificial Intelligence, 360-366 (1994), arXiv: 1302.6823

[lauritzen-local-1988]

Steffen L. Lauritzen and David J. Spiegelhalter, “Local computations with probabilities on graphical structures and their application to expert systems”, Journal of the Royal Statistical Society B 50, 157-194 (1988), DOI: 10.1111/j.2517-6161.1988.tb01721.x [sci-hub, @tor]

Examples

>>> g = gt.Graph([(0, 2), (1, 2), (2, 3), (3, 4), (2, 4)])
>>> t, cliques, seps = gt.junction_tree(g)
>>> print(sorted(sorted(cliques[v]) for v in t.vertices()))
[[0, 1, 2], [2, 3, 4]]

For a \(3\times 4\) lattice, the junction tree is a path of cliques of the completed graph, which we draw with the vertices of every clique as labels:

>>> g = gt.lattice([3, 4])
>>> t, cliques, seps = gt.junction_tree(g)
>>> label = t.new_vp("string", vals=[",".join(map(str, sorted(cliques[v])))
...                                  for v in t.vertices()])
>>> tpos = t.new_vp("vector<double>",
...                 vals=[(i, 0) for i in range(t.num_vertices())])
>>> gt.graph_draw(t, tpos, vertex_text=label, vertex_fill_color="#cccccc",
...               edge_color="#999999", vertex_size=75,
...               vertex_font_size=13,
...               vertex_shape="square", output_size=(1000, 120),
...               output="junction_tree-lattice.pdf")
<...>
../_images/junction_tree-lattice.png

Junction tree of a \(3\times 4\) lattice, with the vertices of every clique given in the labels.#