@@ -67,6 +67,7 @@ def __init__(
6767 mobile_participants_percent ,
6868 additional_participants ,
6969 schema_additional_participants ,
70+ random_topology_probability ,
7071 ):
7172 """
7273 Initialize the scenario.
@@ -117,6 +118,7 @@ def __init__(
117118 mobile_participants_percent (float): Percentage of mobile participants.
118119 additional_participants (list): List of additional participants.
119120 schema_additional_participants (str): Schema for additional participants.
121+ random_topology_probability (float): Probability for random topology.
120122 """
121123 self .scenario_title = scenario_title
122124 self .scenario_description = scenario_description
@@ -161,6 +163,7 @@ def __init__(
161163 self .mobile_participants_percent = mobile_participants_percent
162164 self .additional_participants = additional_participants
163165 self .schema_additional_participants = schema_additional_participants
166+ self .random_topology_probability = random_topology_probability
164167
165168 def attack_node_assign (
166169 self ,
@@ -567,8 +570,19 @@ def load_configurations_and_start_nodes(self, additional_participants=None, sche
567570
568571 def create_topology (self , matrix = None ):
569572 import numpy as np
570-
571- if matrix is not None :
573+
574+ if self .scenario .topology == "Random" :
575+ # Create network topology using topology manager (random)
576+ probability = float (self .scenario .random_topology_probability )
577+ logging .info (f"Creating random network topology using erdos_renyi_graph: nodes={ self .n_nodes } , probability={ probability } " )
578+ topologymanager = TopologyManager (
579+ scenario_name = self .scenario_name ,
580+ n_nodes = self .n_nodes ,
581+ b_symmetric = True ,
582+ undirected_neighbor_num = 3 ,
583+ )
584+ topologymanager .generate_random_topology (probability )
585+ elif matrix is not None :
572586 if self .n_nodes > 2 :
573587 topologymanager = TopologyManager (
574588 topology = np .array (matrix ),
@@ -585,7 +599,7 @@ def create_topology(self, matrix=None):
585599 b_symmetric = True ,
586600 undirected_neighbor_num = 2 ,
587601 )
588- elif self .scenario .topology == "fully " :
602+ elif self .scenario .topology == "Fully " :
589603 # Create a fully connected network
590604 topologymanager = TopologyManager (
591605 scenario_name = self .scenario_name ,
@@ -594,20 +608,11 @@ def create_topology(self, matrix=None):
594608 undirected_neighbor_num = self .n_nodes - 1 ,
595609 )
596610 topologymanager .generate_topology ()
597- elif self .scenario .topology == "ring " :
611+ elif self .scenario .topology == "Ring " :
598612 # Create a partially connected network (ring-structured network)
599613 topologymanager = TopologyManager (scenario_name = self .scenario_name , n_nodes = self .n_nodes , b_symmetric = True )
600614 topologymanager .generate_ring_topology (increase_convergence = True )
601- elif self .scenario .topology == "random" :
602- # Create network topology using topology manager (random)
603- topologymanager = TopologyManager (
604- scenario_name = self .scenario_name ,
605- n_nodes = self .n_nodes ,
606- b_symmetric = True ,
607- undirected_neighbor_num = 3 ,
608- )
609- topologymanager .generate_topology ()
610- elif self .scenario .topology == "star" and self .scenario .federation == "CFL" :
615+ elif self .scenario .topology == "Star" and self .scenario .federation == "CFL" :
611616 # Create a centralized network
612617 topologymanager = TopologyManager (scenario_name = self .scenario_name , n_nodes = self .n_nodes , b_symmetric = True )
613618 topologymanager .generate_server_topology ()
0 commit comments