File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -24,16 +24,22 @@ def make_pubsub_msg(
24
24
)
25
25
26
26
27
- # TODO: Implement sparse connect
28
27
async def dense_connect (hosts : Sequence [IHost ]) -> None :
29
28
await connect_some (hosts , 10 )
30
29
31
30
32
- # FIXME: `degree` is not used at all
33
31
async def connect_some (hosts : Sequence [IHost ], degree : int ) -> None :
32
+ """
33
+ Connect each host to up to 'degree' number of other hosts.
34
+ Creates a sparse network topology where each node has limited connections.
35
+ """
34
36
for i , host in enumerate (hosts ):
35
- for host2 in hosts [i + 1 :]:
36
- await connect (host , host2 )
37
+ connections_made = 0
38
+ for j in range (i + 1 , len (hosts )):
39
+ if connections_made >= degree :
40
+ break
41
+ await connect (host , hosts [j ])
42
+ connections_made += 1
37
43
38
44
39
45
async def one_to_all_connect (hosts : Sequence [IHost ], central_host_index : int ) -> None :
You can’t perform that action at this time.
0 commit comments