summaryrefslogtreecommitdiff
path: root/xmake/core/base/graph.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 /xmake/core/base/graph.lua
parent25c2b873ac04a5ef3d13a077b2ce8314f6b128f7 (diff)
fix remove vertex
Diffstat (limited to 'xmake/core/base/graph.lua')
-rw-r--r--xmake/core/base/graph.lua28
1 files changed, 14 insertions, 14 deletions
diff --git a/xmake/core/base/graph.lua b/xmake/core/base/graph.lua
index dcb274318..658b71e73 100644
--- a/xmake/core/base/graph.lua
+++ b/xmake/core/base/graph.lua
@@ -107,17 +107,15 @@ function graph:remove_vertex(v)
self._edges_map[v] = nil
self._adjacent_edges[v] = nil
-- remove the adjacent edge with this vertex in the other vertices
- if not self:is_directed() then
- for _, w in ipairs(self:vertices()) do
- local edges = self:adjacent_edges(w)
- if edges then
- table.remove_if(edges, function (_, e)
- if e:other(w) == v then
- self._edges_map[w] = nil
- return true
- end
- end)
- end
+ for _, w in ipairs(self:vertices()) do
+ local edges = self:adjacent_edges(w)
+ if edges then
+ table.remove_if(edges, function (_, e)
+ if e:other(w) == v then
+ self._edges_map[w] = nil
+ return true
+ end
+ end)
end
end
@@ -176,7 +174,7 @@ function graph:partial_topo_sort_next()
-- recompute all nodes if has dirty nodes
if self._partial_topo_dirty then
- self:_partial_topo_sort_recompute_all()
+ self:_partial_topo_sort_recompute_dirty()
end
-- check if we already detected a cycle
@@ -487,8 +485,10 @@ function graph:_partial_topo_sort_init()
return true
end
--- recompute all nodes
-function graph:_partial_topo_sort_recompute_all()
+-- recompute all dirty nodes
+--
+-- TODO we recompute all nodes now, but we should optimize to recompute only dirty nodes
+function graph:_partial_topo_sort_recompute_dirty()
self._partial_topo_in_progress = false
self._partial_topo_in_degree = nil
self._partial_topo_queue = nil