@@ -375,6 +375,24 @@ pub(crate) fn variant_to_full_slash(variant: &BTreeMap<String, String>) -> Strin
375375 }
376376}
377377
378+ /// Build a hint string listing available variants for a problem name.
379+ /// Returns an empty string if there is only one variant (nothing to disambiguate).
380+ pub ( crate ) fn variant_hint_for ( graph : & ReductionGraph , name : & str ) -> String {
381+ let variants = graph. variants_for ( name) ;
382+ if variants. len ( ) <= 1 {
383+ return String :: new ( ) ;
384+ }
385+ let list: Vec < String > = variants
386+ . iter ( )
387+ . map ( |v| format ! ( "{}{}" , name, variant_to_full_slash( v) ) )
388+ . collect ( ) ;
389+ format ! (
390+ "\n Tip: try specifying a variant. Available variants for {}:\n {}\n " ,
391+ name,
392+ list. join( ", " ) ,
393+ )
394+ }
395+
378396/// Format a problem node as **bold name/variant** in slash notation.
379397/// This is the single source of truth for "name/variant" display.
380398fn fmt_node ( _graph : & ReductionGraph , name : & str , variant : & BTreeMap < String , String > ) -> String {
@@ -550,8 +568,10 @@ pub fn path(
550568 out. emit_with_default_name ( "" , & text, & json)
551569 }
552570 None => {
571+ let variant_hint = variant_hint_for ( & graph, & dst_spec. name ) ;
553572 anyhow:: bail!(
554- "No reduction path from {} to {}\n \n \
573+ "No reduction path from {} to {}\n \
574+ {variant_hint}\n \
555575 Usage: pred path <SOURCE> <TARGET>\n \
556576 Example: pred path MIS QUBO\n \n \
557577 Run `pred show {}` and `pred show {}` to check available reductions.",
@@ -578,8 +598,10 @@ fn path_all(
578598 graph. find_paths_up_to ( src_name, src_variant, dst_name, dst_variant, max_paths + 1 ) ;
579599
580600 if all_paths. is_empty ( ) {
601+ let variant_hint = variant_hint_for ( graph, dst_name) ;
581602 anyhow:: bail!(
582- "No reduction path from {} to {}\n \n \
603+ "No reduction path from {} to {}\n \
604+ {variant_hint}\n \
583605 Usage: pred path <SOURCE> <TARGET> --all\n \
584606 Example: pred path MIS QUBO --all\n \n \
585607 Run `pred show {}` and `pred show {}` to check available reductions.",
0 commit comments