use crate::{GlobalArgs, NumThreadsArg, get_thread_pool};
use anyhow::Result;
use clap::Parser;
use webgraph_algo::{combine_labels, labels_to_ranks};
use std::path::PathBuf;
use super::llp::store_perm;
#[derive(Parser, Debug)]
#[command(name = "llp-combine", about = "Combines the pre-computed labels from Layered Label Propagation into a permutation.", long_about = None)]
pub struct CliArgs {
pub work_dir: PathBuf,
pub perm: PathBuf,
#[arg(short, long)]
pub epserde: bool,
#[command(flatten)]
pub num_threads: NumThreadsArg,
}
pub fn main(_global_args: GlobalArgs, args: CliArgs) -> Result<()> {
let thread_pool = get_thread_pool(args.num_threads.num_threads);
thread_pool.install(|| -> Result<()> {
let labels = combine_labels(args.work_dir)?;
log::info!("Combined labels...");
let rank_perm = labels_to_ranks(&labels);
log::info!("Saving permutation...");
store_perm(&rank_perm, &args.perm, args.epserde)?;
Ok(())
})
}