summaryrefslogtreecommitdiff
path: root/tests/modules/graph/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-23 21:46:33 +0800
committerruki <[email protected]>2025-04-08 15:31:55 +0800
commit9b3f6f86ae92c9fb779fbb898801ab4c70a6390e (patch)
treeebe89913b7c2f1d11ee4db62e4f2df41ea1e25e5 /tests/modules/graph/test.lua
parent25c2b873ac04a5ef3d13a077b2ce8314f6b128f7 (diff)
fix remove vertex
Diffstat (limited to 'tests/modules/graph/test.lua')
-rw-r--r--tests/modules/graph/test.lua23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/modules/graph/test.lua b/tests/modules/graph/test.lua
index a13737b6e..fe1d63e8d 100644
--- a/tests/modules/graph/test.lua
+++ b/tests/modules/graph/test.lua
@@ -110,11 +110,14 @@ function test_paritail_topo_sort_dynamic(t)
if node then
if not dynamic_adjust then
dag:add_edge(1, 4)
- dag:add_edge(2, 9)
- dynamic_adjust = true
+ dag:remove_vertex(6)
end
table.insert(order_vertices, node)
dag:partial_topo_sort_remove(node)
+ if not dynamic_adjust then
+ dag:add_edge(2, 9)
+ dynamic_adjust = true
+ end
else
if has_cycle then
raise("has cycle!")
@@ -148,8 +151,20 @@ function test_paritail_topo_sort_dynamic(t)
for i, v in ipairs(order_path) do
orders[v] = i
end
- table.insert(edges, {1, 4})
- table.insert(edges, {2, 9})
+ edges = {
+ {0, 5},
+ {0, 2},
+ {0, 1},
+ -- {3, 6},
+ {3, 5},
+ {3, 4},
+ {5, 4},
+ -- {6, 4},
+ -- {6, 0},
+ {3, 2},
+ {1, 4},
+ {2, 9}
+ }
for _, e in ipairs(edges) do
t:require(orders[e[1]] < orders[e[2]])
end