@@ -45,26 +45,18 @@ impl ReductionResult for ReductionFVSToCodeGen {
4545 // Internal nodes are indices n, n+1, ..., n+m-1 (sorted), so
4646 // target_solution[j] = position for internal node (n + j).
4747
48- // Build: target_node_index -> evaluation position
49- let num_internal = target_solution. len ( ) ;
50- let mut eval_pos = vec ! [ 0usize ; num_internal] ;
51- for j in 0 ..num_internal {
52- // internal node (n + j) has evaluation position target_solution[j]
53- eval_pos[ j] = target_solution[ j] ;
54- }
48+ // eval_pos[j] = evaluation position for internal node (n + j)
49+ let eval_pos = target_solution;
5550
56- for x in 0 ..n {
51+ for ( x , cfg ) in source_config . iter_mut ( ) . enumerate ( ) {
5752 if let Some ( chain_start_idx) = self . chain_start [ x] {
58- // chain_start_idx is the target node index of x¹
59- // Its position in the internal array = chain_start_idx - n
6053 let start_j = chain_start_idx - n;
6154 let start_pos = eval_pos[ start_j] ;
6255
63- // Check if any right-child user of leaf x⁰ is evaluated after x¹
6456 for & user_idx in & self . right_child_users [ x] {
6557 let user_j = user_idx - n;
6658 if eval_pos[ user_j] > start_pos {
67- source_config [ x ] = 1 ;
59+ * cfg = 1 ;
6860 break ;
6961 }
7062 }
@@ -109,7 +101,7 @@ impl ReduceTo<MinimumCodeGenerationUnlimitedRegisters> for MinimumFeedbackVertex
109101
110102 chain_start[ x] = Some ( next_internal) ;
111103
112- for i in 0 ..d {
104+ for ( i , & neighbor ) in neighbors . iter ( ) . enumerate ( ) {
113105 let node_idx = next_internal + i;
114106 // Left child: predecessor in chain
115107 let left_child = if i == 0 {
@@ -118,7 +110,7 @@ impl ReduceTo<MinimumCodeGenerationUnlimitedRegisters> for MinimumFeedbackVertex
118110 next_internal + i - 1 // previous chain node
119111 } ;
120112 // Right child: leaf y_i⁰
121- let right_child = neighbors [ i ] ; // leaf index = source vertex index
113+ let right_child = neighbor ; // leaf index = source vertex index
122114
123115 left_arcs. push ( ( node_idx, left_child) ) ;
124116 right_arcs. push ( ( node_idx, right_child) ) ;
@@ -130,8 +122,7 @@ impl ReduceTo<MinimumCodeGenerationUnlimitedRegisters> for MinimumFeedbackVertex
130122
131123 debug_assert_eq ! ( next_internal, n + m) ;
132124
133- let target =
134- MinimumCodeGenerationUnlimitedRegisters :: new ( n + m, left_arcs, right_arcs) ;
125+ let target = MinimumCodeGenerationUnlimitedRegisters :: new ( n + m, left_arcs, right_arcs) ;
135126
136127 ReductionFVSToCodeGen {
137128 target,
@@ -161,8 +152,7 @@ pub(crate) fn canonical_rule_example_specs() -> Vec<crate::example_db::specs::Ru
161152 id: "minimumfeedbackvertexset_to_minimumcodegenerationunlimitedregisters" ,
162153 build: || {
163154 let source = issue_example_source( ) ;
164- let reduction =
165- ReduceTo :: <MinimumCodeGenerationUnlimitedRegisters >:: reduce_to( & source) ;
155+ let reduction = ReduceTo :: <MinimumCodeGenerationUnlimitedRegisters >:: reduce_to( & source) ;
166156
167157 // Find a target witness whose extracted source solution matches an optimal FVS
168158 let solver = BruteForce :: new( ) ;
0 commit comments