Skip to content

Commit a4f9c4c

Browse files
committed
graphs/modular_decomposition: add docstrings and indirect doctests for internal functions
1 parent 151d10f commit a4f9c4c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/sage/graphs/graph_decompositions/modular_decomposition.pyx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def corneil_habib_paul_tedder_algorithm(G):
106106

107107
cdef 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

125128
cdef 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

Comments
 (0)