-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Binding for Routing Algorithms (#45)
* Add Binding for Benes Routing Algorithm * Add Binding for AS Waksman Routing Algorithm * Add Test for Routing Algorithms * Update arg for bindings Updated Default arguments name for user documentation
- Loading branch information
1 parent
6bf68dc
commit 400c459
Showing
3 changed files
with
106 additions
and
5 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
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
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,23 @@ | ||
# Testing functionality for routing on an benes network and arbitrary-size (AS) Waksman network. | ||
|
||
import pyzpk | ||
import math | ||
|
||
def test_benes(num_packets): | ||
permutation = pyzpk.integer_permutation(math.ceil(num_packets)) | ||
while permutation.next_permutation(): | ||
routing = pyzpk.get_benes_routing(permutation) | ||
assert pyzpk.valid_benes_routing(permutation, routing) == True | ||
|
||
def test_as_waksman(num_packets): | ||
permutation = pyzpk.integer_permutation(num_packets) | ||
while permutation.next_permutation(): | ||
routing = pyzpk.get_as_waksman_routing(permutation) | ||
assert pyzpk.valid_as_waksman_routing(permutation, routing) == True | ||
|
||
|
||
if __name__ == "__main__": | ||
num_packets = 8 | ||
for i in range(2, num_packets+1): | ||
test_as_waksman(i) | ||
test_benes(num_packets) |