@@ -101,6 +101,7 @@ def __init__(
101101 network_stats_file_name : str ,
102102 nodes_stats_directory : str ,
103103 graph_model : str = 'preferential_attachment' ,
104+ graph_edges : Optional [Set [Tuple [int , int ]]] = None
104105 ):
105106 if num_proposer_nodes < 0 or num_relay_nodes < 0 :
106107 raise RuntimeError ('Number of nodes must be positive' )
@@ -120,10 +121,14 @@ def __init__(
120121 self .num_validator_nodes = num_validator_nodes
121122 self .num_relay_nodes = num_relay_nodes
122123 self .num_nodes = num_proposer_nodes + num_validator_nodes + num_relay_nodes
123- self .graph_model = graph_model
124- self .graph_edges : Set [Tuple [int , int ]] = set ()
125124 self .latency = latency # For now just a shared latency parameter.
126- self .define_network_topology ()
125+
126+ # Network topology related settings
127+ if graph_edges is None :
128+ self .graph_edges : Set [Tuple [int , int ]]
129+ self .define_network_topology (graph_model )
130+ else :
131+ self .graph_edges = graph_edges
127132
128133 # Simulation related settings
129134 self .simulation_time = simulation_time
@@ -496,7 +501,7 @@ def stop_nodes(self, nodes: Optional[Dict[int, TestNode]] = None):
496501 for node in nodes .values ():
497502 node .wait_until_stopped ()
498503
499- def define_network_topology (self ):
504+ def define_network_topology (self , graph_model : str ):
500505 """This function defines the network's topology"""
501506
502507 self .logger .info ('Defining network graph' )
@@ -505,7 +510,7 @@ def define_network_topology(self):
505510 num_nodes = self .num_nodes ,
506511 num_outbound_connections = NUM_OUTBOUND_CONNECTIONS ,
507512 max_inbound_connections = NUM_INBOUND_CONNECTIONS ,
508- model = self . graph_model
513+ model = graph_model
509514 )
510515
511516 # We try to avoid having sink sub-graphs
0 commit comments