webgraph_cli/run/
llp_combine.rs1use crate::{IntSliceFormat, NumThreadsArg, get_thread_pool};
10use anyhow::Result;
11use clap::Parser;
12use webgraph_algo::{combine_labels, labels_to_ranks};
13
14use std::path::PathBuf;
15
16use super::llp::store_perm;
17
18#[derive(Parser, Debug)]
19#[command(name = "llp-combine", about = "Combines the pre-computed labels from Layered Label Propagation into a permutation.", long_about = None, next_line_help = true)]
20pub struct CliArgs {
21 pub work_dir: PathBuf,
24
25 pub perm: PathBuf,
27
28 #[arg(long, value_enum, default_value_t)]
29 pub fmt: IntSliceFormat,
31
32 #[command(flatten)]
34 pub num_threads: NumThreadsArg,
35}
36
37pub fn main(args: CliArgs) -> Result<()> {
38 let thread_pool = get_thread_pool(args.num_threads.num_threads);
39 thread_pool.install(|| -> Result<()> {
40 let labels = combine_labels(args.work_dir)?;
41 log::info!("Combined labels...");
42 let rank_perm = labels_to_ranks(&labels);
43 log::info!("Saving permutation...");
44 store_perm(&rank_perm, &args.perm, args.fmt)?;
45 Ok(())
46 })
47}