forked from cengwins/ahc_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cengwins
committed
Jan 14, 2022
1 parent
27bb6fb
commit ed9ca69
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import os | ||
import sys | ||
import random | ||
|
||
sys.path.insert(0, os.getcwd()) | ||
|
||
import networkx as nx | ||
import matplotlib.pyplot as plt | ||
|
||
from ahc.Channels.Channels import P2PFIFOPerfectChannel,Channel | ||
from ahc.Ahc import Topology | ||
from ahc.Ahc import ComponentRegistry | ||
from ahc.Routing.CGSR.CGSRNode import CGSRNode | ||
|
||
registry = ComponentRegistry() | ||
|
||
def main(): | ||
|
||
G = nx.random_geometric_graph(5, 0.5) | ||
topo = Topology() | ||
topo.construct_from_graph(G, CGSRNode, P2PFIFOPerfectChannel) | ||
nx.draw(G, with_labels=True, font_weight='bold') | ||
plt.draw() | ||
# for ch in topo.channels: | ||
# topo.channels[ch].setPacketLossProbability(random.random()) | ||
# topo.channels[ch].setAverageNumberOfDuplicates(0) | ||
|
||
ComponentRegistry().print_components() | ||
|
||
topo.start() | ||
# while (True): pass | ||
topo.plot() | ||
plt.show() | ||
print(topo.nodecolors) | ||
for component in registry.components: | ||
print(component) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |