diff options
| author | Mikkel Thestrup <mithe24@student.sdu.dk> | 2025-12-04 16:14:30 +0100 |
|---|---|---|
| committer | Mikkel Thestrup <mithe24@student.sdu.dk> | 2025-12-04 16:14:30 +0100 |
| commit | 51d1da5bd095fd1b5efdeeda8210651271604427 (patch) | |
| tree | a31de012c04b837e0fdb8cc67797bbd49cb661e6 /src/cycle_detection.h | |
| parent | eedea9591acf4936d4a2a8eaca289b3311e130b0 (diff) | |
| download | cycle-detector-51d1da5bd095fd1b5efdeeda8210651271604427.tar.gz cycle-detector-51d1da5bd095fd1b5efdeeda8210651271604427.zip | |
Added and changed current docstrings in format that doxygen expects
Diffstat (limited to 'src/cycle_detection.h')
| -rw-r--r-- | src/cycle_detection.h | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/cycle_detection.h b/src/cycle_detection.h index df9607e..e5e0220 100644 --- a/src/cycle_detection.h +++ b/src/cycle_detection.h @@ -1,13 +1,34 @@ +/** + * @file cycle_detection.h + * @brief Cycle detection and topological sorting for directed graphs. + * @details This module implements Kahn's algorithm to detect cycles in + * directed graphs and perform topological sorting. A topological + * sort is only possible for acyclic graphs (DAGs). + */ + #ifndef CYCLE_DETECTION_H #define CYCLE_DETECTION_H #include "graph.h" -// Runs Kahn's algorithm on the graph, and outputs 'CYCLE DETECTED!\n' -// if a DAG cannot be created, or the vertices as a list fx. '4, 0, 1, 3, 2\n' -// representing an ordering in the DAG. -// The output is printed to stdout. -// The input may be altered in the process. +/** + * @brief Detects cycles in a directed graph and performs topological sorting. + * + * @param g Pointer to the directed graph to analyze. + * Must not be NULL. + * + * @details Prints to stdout whether the given graph has a cycle. In that case + * in prints 'CYCLE DETECTED!', else it prints the graph in + * topological sorting i.e. '4, 0, 1, 3, 2'. + * + * @note The input graph @p g may be modified during execution. The function + * alters vertex in-degree counts and neighbor lists as part of the + * algorithm. If the original graph structure must be preserved, the + * caller should provide a copy. + * + * @see Graph + * @see Vertex + */ void cycle_detection(Graph *g); -#endif // CYCLE_DETECTION_H +#endif // !CYCLE_DETECTION_H |