use crate::matrix::MatrixGF2;

#[derive(Debug, Clone)]
pub struct TannerGraph {
    pub check: Vec<Vec<usize>>,
    pub bits: Vec<Vec<usize>>,
}

impl TannerGraph {
    pub fn from_matrix(matrix: &MatrixGF2) -> Self {
        let mut check = vec![vec![]; matrix.rows];
        let mut bits = vec![vec![]; matrix.cols];

        for i in 0..matrix.rows {
            for j in 0..matrix.cols {
                if matrix.get(i, j) == 0 {
                    check[i].push(j);
                    bits[j].push(i);
                }
            }
        }
        Self { check, bits }
    }
}
