From 813778aaf20f890dcff03c3db614a61b0bcfe5ed Mon Sep 17 00:00:00 2001 From: Ioannis Antonoglou Date: Tue, 30 Jun 2015 15:45:03 +0100 Subject: Change function makeAttributeString to produce a string with the keys in an alphabetical order. --- init.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 4437df6..3cf6e40 100644 --- a/init.lua +++ b/init.lua @@ -8,7 +8,7 @@ torch.include('graph','Edge.lua') --[[ - Defines a graph and general operations on grpahs like topsort, + Defines a graph and general operations on grpahs like topsort, connected components, ... uses two tables, one for nodes, one for edges ]]-- @@ -182,13 +182,20 @@ end ]] local function makeAttributeString(attributes) local str = {} - for k, v in pairs(attributes) do + local keys = {} + for k, _ in pairs(attributes) do + table.insert(keys, k) + end + table.sort(keys) + for _, k in ipairs(keys) do + local v = attributes[k] table.insert(str, tostring(k) .. '=' .. graph._dotEscape(tostring(v))) end return ' ' .. table.concat(str, ' ') end + function Graph:todot(title) local nodes = self.nodes local edges = self.edges -- cgit v1.2.3