summaryrefslogtreecommitdiff
path: root/tests/modules/graph/test.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2025-03-21 23:16:34 +0800
committerruki <[email protected]>2025-04-08 15:31:54 +0800
commit53d124455837e9afa2c78e41b88f0f973fdf83e7 (patch)
treeca5272317f7f86602e1bcd8d82bec8d0b7df367c /tests/modules/graph/test.lua
parent093894844d4d7e7e58a7a78d36f04cf59b95ff31 (diff)
get parital single node
Diffstat (limited to 'tests/modules/graph/test.lua')
-rw-r--r--tests/modules/graph/test.lua12
1 files changed, 5 insertions, 7 deletions
diff --git a/tests/modules/graph/test.lua b/tests/modules/graph/test.lua
index da6218f14..c9584a69a 100644
--- a/tests/modules/graph/test.lua
+++ b/tests/modules/graph/test.lua
@@ -42,16 +42,14 @@ function test_paritail_topo_sort(t)
local function partiail_topo_sort(dag)
dag:partial_topo_sort_reset()
+ local node, has_cycle
local order_vertices = {}
- local batch, has_cycle = dag:partial_topo_sort_next()
- while #batch > 0 do
- for _, v in ipairs(batch) do
- table.insert(order_vertices, v)
- end
- batch, has_cycle = dag:partial_topo_sort_next()
- if has_cycle then
+ while true do
+ node, has_cycle = dag:partial_topo_sort_next()
+ if node == nil or has_cycle then
break
end
+ table.insert(order_vertices, node)
end
return order_vertices, has_cycle