File size: 819 Bytes
224e773
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
//! Connectivity analysis

use super::adjacency::AdjacencyMatrix;

pub fn is_strongly_connected(adj: &AdjacencyMatrix) -> bool {
    // Simplified: check if any edge exists (stub)
    for row in adj.matrix() {
        if row.iter().any(|&w| w > 0.0) {
            return true;
        }
    }
    false
}

pub fn find_cycles(adj: &AdjacencyMatrix) -> Vec<Vec<usize>> {
    // Stub: simplified cycle detection
    Vec::new()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn disconnected_graph() {
        let adj = AdjacencyMatrix::new(3);
        assert!(!is_strongly_connected(&adj));
    }

    #[test]
    fn connected_graph() {
        let mut adj = AdjacencyMatrix::new(2);
        adj.set_edge(0, 1, 1.0);
        assert!(is_strongly_connected(&adj));
    }
}