use std::path::PathBuf;
use anyhow::{Context, Result};
use clap::Parser;
#[allow(unused_imports)] use log::{self, debug, info, warn};
use swh_graph::mph::DynMphf;
use swh_graph_stdlib::project_ids::compute_project_ids;
#[derive(Parser, Debug)]
#[command()]
struct Args {
graph_path: PathBuf,
#[arg(long)]
output_path: PathBuf,
#[arg(long, default_value_t = 96)]
num_partitions: usize,
#[arg(long, default_value_t = false)]
print_stats: bool,
}
pub fn main() -> Result<()> {
let args = Args::parse();
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
info!("Loading graph...");
let graph = swh_graph::graph::SwhBidirectionalGraph::new(args.graph_path)
.context("Could not load graph")?
.init_properties()
.load_properties(|props| props.load_maps::<DynMphf>())
.context("Could not load maps")?;
let (stats, _) = compute_project_ids(&graph, args.num_partitions, &args.output_path)?;
if args.print_stats {
println!("{stats}");
}
Ok(())
}