From c7d3037e9db38a8391c2e3bc4c93eaaeaf7a6b46 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 19 Mar 2022 21:13:55 -0700 Subject: [PATCH] graphviz: show topology in multiple lines --- break.tlv | 11 +++++++ graphviz.tlv | 81 ++++++++++++++++++++++++++++++++++++++++++++-------- template.tlv | 11 +++++++ 3 files changed, 91 insertions(+), 12 deletions(-) diff --git a/break.tlv b/break.tlv index b57176f..34cbe78 100644 --- a/break.tlv +++ b/break.tlv @@ -580,6 +580,17 @@ > end > end >end +- __teliva_timestamp: original + sep: + >-- horizontal separator + >function sep(window) + > local y, _ = window:getyx() + > window:mvaddstr(y+1, 0, '') + > local _, cols = window:getmaxyx() + > for col=1,cols do + > window:addstr('_') + > end + >end - __teliva_timestamp: original render: >function render(window) diff --git a/graphviz.tlv b/graphviz.tlv index 5d8594a..0bdd67b 100644 --- a/graphviz.tlv +++ b/graphviz.tlv @@ -580,6 +580,17 @@ > end > end >end +- __teliva_timestamp: original + sep: + >-- horizontal separator + >function sep(window) + > local y, _ = window:getyx() + > window:mvaddstr(y+1, 0, '') + > local _, cols = window:getmaxyx() + > for col=1,cols do + > window:addstr('_') + > end + >end - __teliva_timestamp: original render: >function render(window) @@ -1241,12 +1252,7 @@ > window:addstr(node) > window:addstr(' ') > end - > y, _ = window:getyx() - > window:mvaddstr(y+1, 0, '') - > local lines, cols = window:getmaxyx() - > for col=1,cols do - > window:addstr('_') - > end + > sep(window) >end - __teliva_timestamp: >Sat Mar 19 16:33:19 2022 @@ -1261,12 +1267,7 @@ > window:addstr(node) > window:addstr(' ') > end - > local y, x = window:getyx() - > window:mvaddstr(y+1, 0, '') - > local lines, cols = window:getmaxyx() - > for col=1,cols do - > window:addstr('_') - > end + > sep(window) >end - __teliva_timestamp: >Sat Mar 19 16:35:34 2022 @@ -1308,3 +1309,59 @@ > end > end >end +- __teliva_timestamp: + >Sat Mar 19 21:05:05 2022 + toposort: + >-- stable sort of nodes in a graph + >-- nodes always occur before all their dependencies + >-- disconnected nodes are in alphabetical order + >function toposort(graph) + > -- non-map variables are arrays + > -- result = leaves in graph + > -- candidates = non-leaves + > local inResultMap = {} + > local candidatesMap = nodes(graph) + > local leavesMap = filter(candidatesMap, function(k, v) return graph[k] == nil end) + > local leaves = to_array(leavesMap) + > table.sort(leaves) + > union(inResultMap, leavesMap) + > local result = {leaves} + > subtract(candidatesMap, leavesMap) + > + > function in_result(x, _) return inResultMap[x] end + > function all_deps_in_result(k, _) return all(graph[k], in_result) end + > while true do + > local oldcount = count(candidatesMap) + > if oldcount == 0 then break end + > local inducteesMap = filter(candidatesMap, all_deps_in_result) + > local inductees = to_array(inducteesMap) + > table.sort(inductees) + > union(inResultMap, inducteesMap) + > table.insert(result, 1, inductees) + > subtract(candidatesMap, inducteesMap) + > if oldcount == count(candidatesMap) then + > error('toposort: graph is not connected') + > end + > end + > return result + >end +- __teliva_timestamp: + >Sat Mar 19 21:05:57 2022 + render_basic_stats: + >function render_basic_stats(window) + > bold(window, tostring(#Nodes)..' nodes:') + > local i = 1 + > for _, stratum in ipairs(Nodes) do + > window:addstr('\n ') + > for _, node in ipairs(stratum) do + > window:attrset(curses.A_REVERSE) + > window:addstr(i) + > window:attrset(curses.A_NORMAL) + > window:addstr(' ') + > window:addstr(node) + > window:addstr(' ') + > i = i+1 + > end + > end + > sep(window) + >end diff --git a/template.tlv b/template.tlv index c82d274..586b640 100644 --- a/template.tlv +++ b/template.tlv @@ -580,6 +580,17 @@ > end > end >end +- __teliva_timestamp: original + sep: + >-- horizontal separator + >function sep(window) + > local y, _ = window:getyx() + > window:mvaddstr(y+1, 0, '') + > local _, cols = window:getmaxyx() + > for col=1,cols do + > window:addstr('_') + > end + >end - __teliva_timestamp: original render: >function render(window)