for (int i = 0; i < pair_count; i++) { int winner = pairs[i].winner; int loser = pairs[i].loser; printf("\nAttempting to lock: %s → %s", candidates[winner], candidates[loser]); // Check if adding this edge creates a cycle if (!creates_cycle(winner, loser)) { locked[winner][loser] = true; printf(" ✓ LOCKED\n"); // Visualize current state of locked pairs printf(" Current locked pairs: "); bool has_locked = false; for (int a = 0; a < candidate_count; a++) { for (int b = 0; b < candidate_count; b++) { if (locked[a][b]) { printf("%s→%s ", candidates[a], candidates[b]); has_locked = true; } } } if (!has_locked) printf("none"); printf("\n"); } else { printf(" ✗ SKIPPED (would create cycle)\n"); } }

return true; }

int margin = preferences[pairs[pair_index].winner][pairs[pair_index].loser] - preferences[pairs[pair_index].loser][pairs[pair_index].winner];

=== TIE-BREAKING VISUALIZATION === Total pairs created: 6 --- BEFORE SORTING --- Pair 1: Alice vs Bob Alice got 5 votes Bob got 3 votes Margin: Alice wins by 2 votes

// Feature: Visualize tie-breaking in sorted pairs void visualize_tie_breaking(void) { printf("\n=== TIE-BREAKING VISUALIZATION ===\n"); printf("Total pairs created: %i\n", pair_count);

// Run the tie-breaking visualization add_pairs(); visualize_tie_breaking(); // NEW FEATURE