Skip to content

Commit 5101835

Browse files
Make graph more compact
1 parent beb5a74 commit 5101835

File tree

2 files changed

+584
-578
lines changed

2 files changed

+584
-578
lines changed

src/liberator/graph.clj

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(format (str "\"%s\" [id = \"%s\" %s] \n "
2323
"\"%s\" -> \"%s\" [label = \"true\", id = \"%s\"] \n"
2424
"\"%s\" -> \"%s\" [label=\"false\", id = \"%s\"]\n")
25-
name (clean-id name) (if internal? "style=\"filled\" fillcolor=\"#CCCCCC\"" "")
25+
name (clean-id name) (if internal? "shape=\"octagon\" style=\"filled\" fillcolor=\"#CCCCCC\"" "")
2626
name then (clean-id (str name "_" then))
2727
name else (clean-id (str name "_" else ))))
2828
'defaction
@@ -57,6 +57,7 @@
5757
(defn rank-handler-groups [handlers]
5858
(->> handlers
5959
(group-by (fn [[name status]] (int (/ status 100))))
60+
(remove #(#{4 5} (first %)))
6061
vals
6162
(map (fn [sg] (map first sg)))
6263
(map rank-same)
@@ -71,6 +72,8 @@
7172
decisions (->> nodes
7273
(filter #(= 'defdecision (first %)))
7374
(map second))
75+
conneg-decisions (filter #(.endsWith (name %) "available?")
76+
decisions)
7477
handlers (->> nodes
7578
(filter #(= 'defhandler (first %)))
7679
(map (fn [[_ name status _]] [name status])))
@@ -79,16 +82,19 @@
7982
(map second))]
8083
{:nodes nodes
8184
:decisions decisions
85+
:conneg-decisions conneg-decisions
8286
:handlers handlers
8387
:actions actions}))
8488

8589
(defn generate-graph-dot []
86-
(let [{:keys [nodes handlers actions]} (parse-source-definitions)]
90+
(let [{:keys [nodes conneg-decisions handlers actions]} (parse-source-definitions)]
91+
(prn conneg-decisions)
8792
(->> nodes
8893
(map to-graph)
8994
(remove nil?)
9095
(concat (rank-handler-groups handlers))
9196
(concat (rank-same (remove #{'initialize-context} actions)))
97+
(concat (rank-same (remove #{'initialize-context} conneg-decisions)))
9298
(apply str)
9399
(format (str "digraph{\nid=\"trace\"; size=\"1000,1000\"; page=\"1000,1000\";\n\n"
94100
"edge[fontname=\"sans-serif\"]\n"

0 commit comments

Comments
 (0)