<commit_before>extern crate nalgebra as na;

use dstream::dstream2d::{TheWorld, DG, RawData, GridPoint};
use na::*;
use petgraph::{Graph};
use petgraph::graph::NodeIndex;
use petgraph::algo::*;
use petgraph::visit::*;

#[test]
fn test_graph_works_as_expected() {
    println!("-----graph behavior");
    let mut g = Graph::<(usize, usize), (usize, usize)>::new();

    let n1 = g.add_node((0,0));
    let n2 = g.add_node((0,1));
    let n3 = g.add_node((1,0));
    let n4 = g.add_node((1,4));
    let n5 = g.add_node((1,5));

    g.extend_with_edges(&[(n1, n2)]);
    g.extend_with_edges(&[(n1, n3)]);
    g.extend_with_edges(&[(n4, n5)]);

    let edge_count = g.edge_count();
    let node_count = g.node_count();

    println!("test edge count: {}", edge_count);
    println!("test node count: {}", node_count);

    for n in g.node_indices() {
        let nsu = g.neighbors_undirected(n);
        let esu = g.edges(n);
        println!("for node {}", n.index());
        for nu in nsu {
            println!("-- neighbor visited");
        }
    }

    //http://math.stackexchange.com/questions/551889/checking-if-a-graph-is-fully-connected
    println!("for graph with n nodes, then A^n, where A the adj matrix, should have no zero elements");
    let adj_mat = g.adjacency_matrix();

    fn convert_graph_adj_mat_to_nalgebra_mat2() {
        //TODO
    }

}

#[test]
fn test_mark_and_remove_and_reset_spore_adics() {
    //TODO
    assert!(false);
}

#[test]
fn test_is_a_grid_cluster() {
    //TODO
    assert!(false);
}

#[test]
fn test_is_inside_grid() {
    //TODO
    assert!(false);
}
<commit_msg>wip try to assemble a Mat2...<commit_after>extern crate nalgebra as na;

use dstream::dstream2d::{TheWorld, DG, RawData, GridPoint};
use na::{Mat2, Vec2, Row};
use petgraph::{Graph};
use petgraph::graph::NodeIndex;
use petgraph::algo::*;
use petgraph::visit::*;

#[test]
fn test_graph_works_as_expected() {
    println!("-----graph behavior");
    let mut g = Graph::<(usize, usize), (usize, usize)>::new();

    let n1 = g.add_node((0,0));
    let n2 = g.add_node((0,1));
    let n3 = g.add_node((1,0));
    let n4 = g.add_node((1,4));
    let n5 = g.add_node((1,5));

    g.extend_with_edges(&[(n1, n2)]);
    g.extend_with_edges(&[(n1, n3)]);
    g.extend_with_edges(&[(n4, n5)]);

    let edge_count = g.edge_count();
    let node_count = g.node_count();

    println!("test edge count: {}", edge_count);
    println!("test node count: {}", node_count);

    for n in g.node_indices() {
        let nsu = g.neighbors_undirected(n);
        let esu = g.edges(n);
        println!("for node {}", n.index());
        for nu in nsu {
            println!("-- neighbor visited");
        }
    }

    //http://math.stackexchange.com/questions/551889/checking-if-a-graph-is-fully-connected
    println!("for graph with n nodes, then A^n, where A the adj matrix, should have no zero elements");
    let adj_mat = g.adjacency_matrix();

    fn convert_graph_adj_mat_to_nalgebra_mat2() {
        //TODO
        let g = Graph::<(usize, usize), (usize, usize)>::new();
        let mut m2 : Mat2<f64> = na::one();

        for n1 in g.node_indices() {
            let mut neighs_v = Vec::new();
            let neighs = g.neighbors_undirected(n1);
            //TODO ugly way to covert iterator to vector
            for neigh in neighs {
                neighs_v.push(neigh);
            }

            let mut the_row: Vec<f64> = Vec::new();
            let mut the_vec_rows: Vec2<f64> = na::zero();

            for n2 in g.node_indices() {
                if ! neighs_v.contains(&n2) {
                    println!("does not contain");
                    the_row.push(1.0);
                    *the_vec_rows.index_mut(1 as usize) = 1.0;

                } else {
                    the_row.push(0.0);
                }

            }
//            m2.set_row(n1.index(), the_row);
        }


    }

}

#[test]
fn test_mark_and_remove_and_reset_spore_adics() {
    //TODO
    assert!(false);
}

#[test]
fn test_is_a_grid_cluster() {
    //TODO
    assert!(false);
}

#[test]
fn test_is_inside_grid() {
    //TODO
    assert!(false);
}

{'fraction_non_alphanumeric': 0.16831683168316833, 'fraction_numerical': 0.020043467761410288, 'mean_word_length': 2.5311167945439044, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '900657', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1512, 'n_words': 322}