summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Iterators.lua
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-04-08 17:23:59 +0000
committerKarl Berry <karl@freefriends.org>2019-04-08 17:23:59 +0000
commit9da8ac113f97e68e91e3a1ef26467f9814eb4312 (patch)
treef36b76c9a982931638dde95501c51072185dec56 /Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Iterators.lua
parente919fa4b004d0ef401808c337d7def5fa259da0f (diff)
pgf revert to previous release (r49607, committed 5jan19)
git-svn-id: svn://tug.org/texlive/trunk@50867 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Iterators.lua')
-rw-r--r--Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Iterators.lua42
1 files changed, 21 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Iterators.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Iterators.lua
index 903291a892d..9e41e1124ee 100644
--- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Iterators.lua
+++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/deprecated/Iterators.lua
@@ -39,40 +39,40 @@ local lib = require("pgf.gd.lib")
-- @return An iterator for traversing \meta{graph} in a topological order.
--
function Iterators.topologicallySorted(dag)
- -- track visited edges
+ -- track visited edges
local deleted_edges = {}
-- collect all sources (nodes with no incoming edges) of the dag
local sources = lib.imap(dag.nodes, function (node) if node:getInDegree() == 0 then return node end end)
-- return the iterator function
- return function ()
+ return function ()
while #sources > 0 do
-- fetch the next sink from the queue
local source = table.remove(sources, 1)
-- get its outgoing edges
local out_edges = source:getOutgoingEdges()
-
+
-- iterate over all outgoing edges we haven't visited yet
for _,edge in ipairs(out_edges) do
- if not deleted_edges[edge] then
- -- mark the edge as visited
- deleted_edges[edge] = true
-
- -- get the node at the other end of the edge
- local neighbour = edge:getNeighbour(source)
-
- -- get a list of all incoming edges of the neighbor that have
- -- not been visited yet
- local in_edges = lib.imap(neighbour:getIncomingEdges(),
- function (edge) if not deleted_edges[edge] then return edge end end)
-
- -- if there are no such edges then we have a new source
- if #in_edges == 0 then
- sources[#sources+1] = neighbour
- end
- end
+ if not deleted_edges[edge] then
+ -- mark the edge as visited
+ deleted_edges[edge] = true
+
+ -- get the node at the other end of the edge
+ local neighbour = edge:getNeighbour(source)
+
+ -- get a list of all incoming edges of the neighbour that have
+ -- not been visited yet
+ local in_edges = lib.imap(neighbour:getIncomingEdges(),
+ function (edge) if not deleted_edges[edge] then return edge end end)
+
+ -- if there are no such edges then we have a new source
+ if #in_edges == 0 then
+ sources[#sources+1] = neighbour
+ end
+ end
end
-- return the current source
@@ -88,4 +88,4 @@ end
-- Done
-return Iterators
+return Iterators \ No newline at end of file