@@ -106,6 +106,9 @@ def corneil_habib_paul_tedder_algorithm(G):
106106
107107cdef object _md_tree_node_to_md_tree_inner_rec(const md_tree_node * n,
108108 CGraphBackend Gb):
109+ """
110+ Utility function for :func:`md_tree_node_to_md_tree`.
111+ """
109112 cdef md_tree_node * c
110113 if deref(n).is_leaf():
111114 return Node.create_leaf(Gb.vertex_label(deref(n).vertex))
@@ -123,6 +126,29 @@ cdef object _md_tree_node_to_md_tree_inner_rec(const md_tree_node *n,
123126
124127
125128cdef object md_tree_node_to_md_tree(const md_tree_node * n, CGraphBackend Gb):
129+ """
130+ This function converts a modular decomposition tree (given as a pointer to a
131+ md_tree_node) into an object of the Python class Node (which is then
132+ converted into the correct output by :meth:`Graph.modular_decomposition`).
133+
134+ The graph backend is needed to convert the int stored into the md_tree_node
135+ into the corresponding vertex of the Python graph.
136+
137+ This function deals with the case of an empty tree and then delegates the
138+ actual conversion to :func:`_md_tree_node_to_md_tree_inner_rec`.
139+
140+ TESTS
141+
142+ Indirect doctests::
143+
144+ sage: from sage.graphs.graph_decompositions.modular_decomposition import *
145+ sage: corneil_habib_paul_tedder_algorithm(Graph(1))
146+ NORMAL [0]
147+ sage: corneil_habib_paul_tedder_algorithm(Graph(2))
148+ PARALLEL [NORMAL [0], NORMAL [1]]
149+ sage: corneil_habib_paul_tedder_algorithm(graphs.CompleteGraph(3))
150+ SERIES [NORMAL [1], NORMAL [2], NORMAL [0]]
151+ """
126152 if n == NULL :
127153 return Node(NodeType.EMPTY)
128154 else :
0 commit comments