Skip to content

Commit

Permalink
Rewrite tests to find cycles and types with new function
Browse files Browse the repository at this point in the history
  • Loading branch information
biphy committed Sep 18, 2023
1 parent a34c7aa commit eb3ddab
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/network_utilities_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,30 @@ p2 = [0 0 0 0 -1; -1 0 0 0 0; 0 -1 0 0 0; 0 0 1 0 0; 0 0 0 1 0]
@test is_same_set_of_networks(unique_network_additions(t2, 1), unique_cycle_addition(t2))
@test is_same_set_of_networks(unique_network_additions(s1, 1), unique_cycle_addition(s1))
@test is_same_set_of_networks(unique_network_additions(s3, 1), unique_cycle_addition(s3))
@test is_same_set_of_networks(unique_network_additions(p2, 1), unique_cycle_addition(p2))
@test is_same_set_of_networks(unique_network_additions(p2, 1), unique_cycle_addition(p2))

# Test find_all_cycles_and_types. Note that the outputs of find_all_cycles_and_types are sorted by the cycle length (ascending order)
connectivity = [0 0 0 1 -1;-1 0 0 0 0;0 -1 0 0 0;0 0 -1 0 0;0 0 0 -1 0]
cycle, type = find_all_cycles_and_types(connectivity)
@test cycle[1] == [1, 2, 3, 4]
@test type[1] == "negative"

connectivity = [1 0 0 0 -1;-1 0 0 0 0;0 -1 0 0 0;0 0 -1 0 0;0 0 0 -1 0]
cycle, type = find_all_cycles_and_types(connectivity)
@test cycle[1] == [1]
@test type[1] == "positive"

connectivity = [0 0 0 0 -1;-1 0 0 1 0;0 -1 0 0 0;0 0 -1 0 0;0 0 0 -1 0]
cycle, type = find_all_cycles_and_types(connectivity)
@test cycle[1] == [2, 3, 4]
@test type[1] == "positive"

connectivity = [0 0 0 0 -1;-1 0 0 0 0;0 -1 0 1 0;0 0 -1 0 0;0 0 0 -1 0]
cycle, type = find_all_cycles_and_types(connectivity)
@test cycle[1] == [3, 4]
@test type[1] == "negative"

connectivity = [0 0 0 0 -1;-1 0 0 0 0;0 -1 0 -1 0;0 0 -1 0 0;0 0 0 -1 0]
cycle, type = find_all_cycles_and_types(connectivity)
@test cycle[1] == [3, 4]
@test type[1] == "positive"

0 comments on commit eb3ddab

Please sign in to comment.