summaryrefslogtreecommitdiff
path: root/graph-checker/src/main.rs
blob: 677e03779e61af9fb0baf759560d8eb35e6bcdb0 (plain)
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
48
49
50
51
52
53
54
// use std::io::{self, BufRead};
use rayon::prelude::*;
use sqlx::migrate::MigrateDatabase;
// use std::sync::{Arc, Mutex};
use std::time::Instant;
use tokio;

mod graph;

mod geng;
use crate::geng::GengIterator;

mod compute;

#[tokio::main]
async fn main() -> Result<(), sqlx::Error> {
    dotenv::dotenv().ok();
    let database_url =
        std::env::var("DATABASE_URL").expect("Expected DATABASE_URL in env");
    if !sqlx::Sqlite::database_exists(&database_url).await? {
        sqlx::Sqlite::create_database(&database_url).await?;
    }
    let db = sqlx::SqlitePool::connect(&database_url).await?;
    let _ = sqlx::query!(
        "CREATE TABLE IF NOT EXISTS graphs (g6 VARCHAR NOT NULL);"
    )
    .execute(&db)
    .await;

    let gi = GengIterator::new(6);

    // let res: Vec<_> =
    //     gi.par_bridge().map(compute::dominating_numbers).collect();
    // let res: Vec<_> = gi.map(compute::dominating_numbers).collect();

    for pair in &res {
        if let Some(cardinality) = pair.1 {
            println!("{} {:?} {:?}", pair.0, cardinality, pair.2);
        }
    }

    // let start = Instant::now();
    // let res = gi
    //     .par_bridge()
    //     .map(compute::apply_theorems)
    //     .collect::<Vec<_>>();
    //
    // let elapsed = start.elapsed();
    // let time = elapsed.as_nanos();
    // println!("len = {}", res.len());
    // println!("Time elapsed: {}s", time as f64 / 1e9);

    Ok(())
}