use crate::{IntSliceFormat, 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, next_line_help = true)]
pub struct CliArgs {
pub work_dir: PathBuf,
pub perm: PathBuf,
#[arg(long, value_enum, default_value_t)]
pub fmt: IntSliceFormat,
#[command(flatten)]
pub num_threads: NumThreadsArg,
}
pub fn main(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.fmt)?;
Ok(())
})
}