File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -410,17 +410,17 @@ def create_cycle_graph(
410410
411411 # Graph is a simply cycle graph with all nodes connected in a loop, including both ends.
412412 # Ensure each node has at least 8 outbound connections by making 7 more outbound connections
413- for node in graph .nodes ():
414- logger .debug (f"Creating additional connections for node { node } " )
413+ for src_node in graph .nodes ():
414+ logger .debug (f"Creating additional connections for node { src_node } " )
415415 for _ in range (8 ):
416416 # Choose a random node to connect to
417- # Make sure it's not the same node and they aren't already connected
418- potential_nodes = [ node for node in range (n ) if n != node and not graph .has_edge (node , n ) ]
417+ # Make sure it's not the same node and they aren't already connected in either direction
418+ potential_nodes = [ dst_node for dst_node in range (n ) if dst_node != src_node and not graph .has_edge (dst_node , src_node ) and not graph . has_edge ( src_node , dst_node ) ]
419419 if potential_nodes :
420420 chosen_node = random .choice (potential_nodes )
421- graph .add_edge (node , chosen_node )
422- logger .debug (f"Added edge: { node } :{ chosen_node } " )
423- logger .debug (f"Node { node } edges: { graph .edges (node )} " )
421+ graph .add_edge (src_node , chosen_node )
422+ logger .debug (f"Added edge: { src_node } :{ chosen_node } " )
423+ logger .debug (f"Node { src_node } edges: { graph .edges (src_node )} " )
424424
425425 # calculate degree
426426 degree_dict = dict (graph .degree (graph .nodes ()))
You can’t perform that action at this time.
0 commit comments