diff options
author | koray kavukcuoglu <koray@kavukcuoglu.org> | 2015-06-30 21:16:38 +0300 |
---|---|---|
committer | koray kavukcuoglu <koray@kavukcuoglu.org> | 2015-06-30 21:16:38 +0300 |
commit | 2fc58236b5c9a22812e9f6b3b7cf14588053786f (patch) | |
tree | dc1e9489b79aea390a787f4fb8c47c04f75a8b52 | |
parent | 2835392e2ad31cce1f4186b340b7f3b9233946e4 (diff) | |
parent | 813778aaf20f890dcff03c3db614a61b0bcfe5ed (diff) |
Merge pull request #15 from IoannisAntonoglou/master
Change function makeAttributeString to produce a string with the keys…
-rw-r--r-- | init.lua | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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 |