Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/graph.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIoannis Antonoglou <ioannisa@google.com>2015-06-30 17:45:03 +0300
committerIoannis Antonoglou <ioannisa@google.com>2015-06-30 17:46:34 +0300
commit813778aaf20f890dcff03c3db614a61b0bcfe5ed (patch)
treedc1e9489b79aea390a787f4fb8c47c04f75a8b52
parent2835392e2ad31cce1f4186b340b7f3b9233946e4 (diff)
Change function makeAttributeString to produce a string with the keys in an alphabetical order.
-rw-r--r--init.lua11
1 files 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