From c3bef6d344f095964245c695cfedfac0ffaa3d8d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 28 Nov 2023 03:03:55 +0100 Subject: [PATCH] Chain-Load: implement graph statistic computation - iterate over all nodes and classify them - group per level - book in per level statistics into the Indicator records - close global averages ...just coded, not yet tested... --- tests/vault/gear/test-chain-load.hpp | 75 ++++++++++++++++++++++++++-- wiki/thinkPad.ichthyo.mm | 42 ++++++++++++---- 2 files changed, 101 insertions(+), 16 deletions(-) diff --git a/tests/vault/gear/test-chain-load.hpp b/tests/vault/gear/test-chain-load.hpp index 9ce35a9c1..8cbd5da33 100644 --- a/tests/vault/gear/test-chain-load.hpp +++ b/tests/vault/gear/test-chain-load.hpp @@ -245,10 +245,19 @@ namespace test { friend bool isStart (Node const& n) { return isnil (n.pred); }; friend bool isExit (Node const& n) { return isnil (n.succ); }; friend bool isInner (Node const& n) { return not (isStart(n) or isExit(n)); } + friend bool isFork (Node const& n) { return 1 < n.succ.size(); } + friend bool isJoin (Node const& n) { return 1 < n.pred.size(); } + friend bool isLink (Node const& n) { return 1 == n.pred.size() and 1 == n.succ.size(); } + friend bool isKnot (Node const& n) { return isFork(n) and isJoin(n); } + - friend bool isStart (Node const* n) { return n and isStart (*n); }; - friend bool isExit (Node const* n) { return n and isExit (*n); }; - friend bool isInner (Node const* n) { return n and isInner (*n); }; + friend bool isStart (Node const* n) { return n and isStart(*n); }; + friend bool isExit (Node const* n) { return n and isExit (*n); }; + friend bool isInner (Node const* n) { return n and isInner(*n); }; + friend bool isFork (Node const* n) { return n and isFork (*n); }; + friend bool isJoin (Node const* n) { return n and isJoin (*n); }; + friend bool isLink (Node const* n) { return n and isLink (*n); }; + friend bool isKnot (Node const* n) { return n and isKnot (*n); }; }; @@ -533,6 +542,9 @@ namespace test { return move(*this); } + + Statistic computeGraphStatistics(); + private: }; @@ -647,6 +659,23 @@ namespace test { const std::array KEYS = {STAT_SEED,STAT_EXIT,STAT_INNR,STAT_FORK,STAT_JOIN,STAT_LINK,STAT_KNOT}; const uint CAT = KEYS.size(); + namespace { + template + inline auto + buildEvaluations() + { + return std::array, CAT> + { [](NOD& n){ return isStart(n);} + , [](NOD& n){ return isExit(n); } + , [](NOD& n){ return isInner(n);} + , [](NOD& n){ return isFork(n); } + , [](NOD& n){ return isJoin(n); } + , [](NOD& n){ return isLink(n); } + , [](NOD& n){ return isKnot(n); } + }; + } + } + using VecU = std::vector; using LevelSums = std::array; @@ -693,7 +722,7 @@ namespace test { /** * Statistic data calculated for a given chain-load topology */ - struct Staticstic + struct Statistic { uint nodes{0}; uint levels{0}; @@ -702,7 +731,7 @@ namespace test { std::map indicators; explicit - Staticstic (uint lvls) + Statistic (uint lvls) : nodes{0} , levels{lvls} { @@ -742,5 +771,41 @@ namespace test { + template + inline Statistic + TestChainLoad::computeGraphStatistics() + { + auto totalLevels = uint(topLevel()); + auto classify = buildEvaluations(); + Statistic stat(totalLevels); + LevelSums particulars{0}; + size_t level{0}; + uint width{0}; + + for (Node& node : allNodes()) + { + ++width; + for (uint i=0; i - - + + @@ -99423,8 +99423,8 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - + + @@ -99546,6 +99546,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ @@ -99556,11 +99557,12 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- + + - + @@ -99576,11 +99578,17 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
- - - - - + + + + + + + + + + + @@ -99590,6 +99598,18 @@ Date:   Thu Apr 20 18:53:17 2023 +0200
+ + + + + + + + + + + +