1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Depth-First Search (DFS, Generic, Production-Grade)
//!
//! Performs a depth-first traversal on a graph represented as an adjacency list.
//!
//! # Type Parameters
//! * `T`: Node type. Must implement `Eq` + `Hash` + `Clone`.
//!
//! # Arguments
//! * `graph` - Reference to adjacency list: `&HashMap<T, Vec<T>>`.
//! * `start` - The starting node.
//!
//! # Returns
//! * `Vec<T>` - The order of nodes visited in DFS.
//!
//! # Example
//! ```rust
//! use std::collections::HashMap;
//! use pofk_algorithm::graph_algorithms::dfs::dfs;
//! let mut graph = HashMap::new();
//! graph.insert(1, vec![2, 3]);
//! graph.insert(2, vec![4]);
//! graph.insert(3, vec![]);
//! graph.insert(4, vec![]);
//! let order = dfs(&graph, 1);
//! assert_eq!(order, vec![1, 2, 4, 3]);
//! ```
use ;