|
| 1 | +#include <stinger_net/stinger_alg.h> |
1 | 2 | #include "scc_test.h" |
2 | 3 |
|
3 | 4 | #define restrict |
@@ -82,37 +83,33 @@ TEST_F(SCCTest, UndirectedGraph) { |
82 | 83 |
|
83 | 84 |
|
84 | 85 | TEST_F(SCCTest, UndirectedGraphDumbbell) { |
85 | | - stinger_insert_edge_pair(S, 0, 0, 1, 1, 1); |
86 | | - stinger_insert_edge_pair(S, 0, 0, 2, 1, 1); |
87 | | - stinger_insert_edge_pair(S, 0, 0, 3, 1, 1); |
88 | | - stinger_insert_edge_pair(S, 0, 1, 2, 1, 1); |
89 | | - stinger_insert_edge_pair(S, 0, 1, 3, 1, 1); |
90 | | - stinger_insert_edge_pair(S, 0, 2, 3, 1, 1); |
91 | | - |
92 | | - stinger_insert_edge_pair(S, 0, 3, 4, 1, 1); |
93 | | - |
94 | | - stinger_insert_edge_pair(S, 0, 4, 5, 1, 1); |
95 | | - stinger_insert_edge_pair(S, 0, 4, 6, 1, 1); |
96 | | - stinger_insert_edge_pair(S, 0, 4, 7, 1, 1); |
97 | | - stinger_insert_edge_pair(S, 0, 5, 6, 1, 1); |
98 | | - stinger_insert_edge_pair(S, 0, 5, 7, 1, 1); |
99 | | - |
100 | 86 | int64_t nv = stinger_max_nv(S); |
101 | 87 | stinger_scc_internal scc_internal; |
102 | 88 | stinger_scc_initialize_internals(S,nv,&scc_internal,4); |
103 | 89 | stinger_connected_components_stats stats; |
104 | 90 | stinger_scc_reset_stats(&stats); |
105 | 91 |
|
106 | | - stinger_edge_update insertion,deletion; |
107 | | - insertion.source = 6; |
108 | | - insertion.destination = 7; |
109 | | - deletion.source = 3; |
110 | | - deletion.destination = 4; |
111 | | - |
112 | | - stinger_insert_edge_pair(S, 0, insertion.source, insertion.destination, 1, 2); |
| 92 | + // Insert (1,2) |
| 93 | + stinger_edge_update insertion = {0}; |
| 94 | + insertion.source = 1; insertion.destination = 2; |
| 95 | + stinger_insert_edge_pair(S, 0, insertion.source, insertion.destination, 1, 1); |
| 96 | + stinger_scc_insertion(S, nv, scc_internal, &stats, &insertion, 1); |
| 97 | + |
| 98 | + // Insert (2,3) |
| 99 | + insertion.source = 2; insertion.destination = 3; |
| 100 | + stinger_insert_edge_pair(S, 0, insertion.source, insertion.destination, 1, 1); |
| 101 | + stinger_scc_insertion(S, nv, scc_internal, &stats, &insertion, 1); |
| 102 | + |
| 103 | + // Insert (3,4) |
| 104 | + insertion.source = 3; insertion.destination = 4; |
| 105 | + stinger_insert_edge_pair(S, 0, insertion.source, insertion.destination, 1, 1); |
| 106 | + stinger_scc_insertion(S, nv, scc_internal, &stats, &insertion, 1); |
| 107 | + |
| 108 | + // Now we have a simple chain, 1-2-3-4 |
| 109 | + // We delete (2,3) breaking the chain into two components 1-2 3-4 |
| 110 | + stinger_edge_update deletion = {0}; |
| 111 | + deletion.source = 2; deletion.destination = 3; |
113 | 112 | stinger_remove_edge_pair(S, 0, deletion.source, deletion.destination); |
114 | | - |
115 | | - stinger_scc_insertion(S,nv,scc_internal,&stats,&insertion,1); |
116 | 113 | stinger_scc_deletion(S,nv,scc_internal,&stats,&deletion,1); |
117 | 114 |
|
118 | 115 | const int64_t* actual_components = stinger_scc_get_components(scc_internal); |
|
0 commit comments