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:
authorkoray kavukcuoglu <koray@kavukcuoglu.org>2013-04-01 03:10:21 +0400
committerkoray kavukcuoglu <koray@kavukcuoglu.org>2013-04-01 03:10:21 +0400
commita39b93620b3e6ee24877ba16021a9b1a5aaff687 (patch)
tree83ee59a84966ea92f99a8c3b28fca9aed05f6842 /init.lua
parent05ab07d164a2a78fe27f67689a7f55f510f09bb7 (diff)
make sure that roots() returns nodes in children insert order which is also consistent with bfs tarversal order.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua5
1 files changed, 2 insertions, 3 deletions
diff --git a/init.lua b/init.lua
index 1ba4d90..9bc15c6 100644
--- a/init.lua
+++ b/init.lua
@@ -133,7 +133,7 @@ function Graph:roots()
for root,i in pairs(rootnodes) do
table.insert(roots, root)
end
- table.sort(roots,function(a,b) return rootnodes[a] < rootnodes[b] end )
+ table.sort(roots,function(a,b) return self.nodes[a] < self.nodes[b] end )
return roots
end
@@ -142,11 +142,10 @@ function Graph:todot()
local edges = self.edges
str = {}
table.insert(str,'digraph G {\n')
- table.insert(str,'node [shape = circle]; ')
+ table.insert(str,'node [shape = oval]; ')
local nodelabels = {}
for i,node in ipairs(nodes) do
local l = '"' .. (node:label() or 'n' .. i) .. '"'
- l = l:gsub('\n','')
nodelabels[node] = 'n' .. i
table.insert(str, '\n' .. nodelabels[node] .. '[label=' .. l .. '];')
end