Fix: Resolve 'low >= high' error in circuit generation - Fixed np.random.randint(2, 2) error when num_additional_edges_max == 1 - Added proper handling for cases where only 1 additional edge is possible - Prevents continuous failures when generating circuits with min_nodes=3

This commit is contained in:
Zijie Yu 2025-06-19 13:28:02 +08:00
parent a32ce9b4f6
commit a3b5982e33

View file

@ -50,8 +50,10 @@ class CoreCircuit:
# print(f"[DEBUG libcircuit] num_additional_edges_max: {num_additional_edges_max}")
num_target_additional_edges = 0
if num_additional_edges_max > 0:
if num_additional_edges_max > 1:
num_target_additional_edges = np.random.randint(2, num_additional_edges_max + 1)
elif num_additional_edges_max == 1:
num_target_additional_edges = 1
# print(f"[DEBUG libcircuit] num_target_additional_edges: {num_target_additional_edges}")
existing_pairs = set()