connectivity: suggest link-add commands for islands
When connectivity shows isolated nodes, print copy-pasteable poc-memory graph link-add commands targeting the highest-degree node in the largest cluster. Closes the diagnose→fix loop.
This commit is contained in:
parent
9a0908fbc6
commit
9d1d690f17
1 changed files with 21 additions and 0 deletions
|
|
@ -579,9 +579,20 @@ fn print_connectivity(results: &[QueryResult], graph: &Graph) {
|
|||
|
||||
let result_set: std::collections::HashSet<&str> = keys.iter().copied().collect();
|
||||
|
||||
// Find the largest cluster to use as link-add target for islands
|
||||
let largest_cluster = components.iter()
|
||||
.max_by_key(|c| c.len())
|
||||
.and_then(|c| if c.len() > 1 {
|
||||
// Pick highest-degree node in largest cluster as link target
|
||||
c.iter().max_by_key(|k| graph.degree(k)).cloned()
|
||||
} else { None });
|
||||
|
||||
let mut islands: Vec<&str> = Vec::new();
|
||||
|
||||
for (i, component) in components.iter().enumerate() {
|
||||
if component.len() == 1 {
|
||||
println!(" island: {}", component[0]);
|
||||
islands.push(&component[0]);
|
||||
} else {
|
||||
println!(" cluster {} ({} nodes):", i + 1, component.len());
|
||||
for node in component {
|
||||
|
|
@ -604,4 +615,14 @@ fn print_connectivity(results: &[QueryResult], graph: &Graph) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Suggest link-add commands for islands
|
||||
if !islands.is_empty() {
|
||||
if let Some(ref hub) = largest_cluster {
|
||||
println!("\nFix islands:");
|
||||
for island in &islands {
|
||||
println!(" poc-memory graph link-add {} {}", island, hub);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue