In [1]:
%run imports.py
In [2]:
x = Bidirectional_Ring(8)
x.draw()
In [3]:
x.state()
Out[3]:
In [4]:
Bidirectional_Line(6).draw()
In [5]:
Random_Line_Network(16).draw()
In [6]:
Random_Line_Network(16, sparsity=0).draw()
In [7]:
Random_Line_Network(16, sparsity=0.5).draw()
In [8]:
Random_Line_Network(16, sparsity=float('inf')).draw()
In [9]:
x = Unidirectional_Ring(5)
In [10]:
x.state()
Out[10]:
In [11]:
lcr = LCR(x)
In [12]:
print lcr.r, "rounds"
In [13]:
print lcr.message_count, "messages"
In [14]:
x.state()
Out[14]:
In [15]:
x = Random_Line_Network(6)
In [16]:
#Elect a Leader
SynchFloodMax(x, params={'verbosity': Algorithm.QUIET})
Out[16]:
In [17]:
#Construct a BFS tree rooted at the Leader
SynchBFS(x)
Out[17]:
In [18]:
SynchConvergeHeight(x, params={'draw':True})
Out[18]:
In [19]:
x.state()
Out[19]:
In [20]:
x = Random_Line_Network(6)
A = Chain(SynchFloodMax(), Chain(SynchBFS(), SynchConvergeHeight()), params={'verbosity':Algorithm.QUIET})
A(x)
In [ ]:
In [21]:
x.state()
Out[21]:
A basic algorithm, with improved message complexity: HS
In [22]:
x = Bidirectional_Ring(8)
In [23]:
# hs = SynchHS(x)
In [24]:
# Message Complexity
In [25]:
# print hs.message_count, "messages"
In [26]:
benchmark(SynchLubyMIS, Random_Line_Network, assertLubyMIS)
In [27]:
benchmark(LCR, Bidirectional_Ring, assertLeaderElection)
In [28]:
benchmark(AsyncLCR, Unidirectional_Ring, assertLeaderElection)
In [29]:
def Artificial_LE_Network(n):
x = Random_Line_Network(n)
for p in x:
if p.UID == n-1:
p.state['status'] = 'leader'
return x
In [30]:
benchmark(SynchBFS, Artificial_LE_Network, assertBFS)