This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-12
Channels
- # announcements (15)
- # babashka (8)
- # babashka-sci-dev (8)
- # beginners (19)
- # biff (18)
- # cider (7)
- # clj-kondo (1)
- # clojure (6)
- # clojure-europe (24)
- # clojure-norway (10)
- # clojure-spec (1)
- # clojurescript (11)
- # conjure (1)
- # core-async (1)
- # cursive (3)
- # devops (1)
- # emacs (1)
- # fulcro (1)
- # helix (4)
- # keechma (1)
- # off-topic (19)
- # pathom (4)
- # reagent (2)
- # reitit (1)
- # shadow-cljs (8)
- # spacemacs (1)
- # vim (7)
there was a talk about rewriting some court case management system in Clojure, starting with a small piece. they talked about juvenile detention and how the incentives of the court and the police are misaligned. does anyone know which talk was it? I'd like to recommend it to someone.
Did anyone play around with https://github.com/aysylu/loom?
I'm trying to put int tuples like this one [1 :attr 2]
and get it to calculate a shortest path. I can easily do the case where I specify [1 2]
as an edge but I want each edge to be named :thinking_face:
Is there a way to name each edge?
Figured it out by using an external map. Not sure if it's the best way :thinking_face:
(def edges [[1 :a1 2]
[1 :a2 2]
[2 :b 3]
[3 :c 4]])
(def indexed-edges (->> edges
(map (fn [[k _ v :as link]]
{[k v] #{link}}))
(reduce (partial merge-with into) {})))
(def dg (apply loom.graph/digraph (keys indexed-edges)))
(->> (loom.alg/shortest-path dg 1 3)
(#(map vector (butlast %) (rest %)))
(map indexed-edges)
(reduce into))
output:
#{[1 :a2 2] [2 :b 3] [1 :a1 2]}
Long time since I used loom but I think this namespaces https://cljdoc.org/d/aysylu/loom/1.0.2/api/loom.attr if for adding attributes to nodes, edges, etc
Oh. I don't want to decorate my graph after creation as it still means that I'll have to do a second pass just to add these edge names. I thought I'll start with three-tuple and it could work like this.
Also if I do a second-pass addition then I'll have to calculate what each edge points into. And I already do it in my example as I construct the map using merge-with
. :thinking_face:
I think that highlighting is the best use of loom.attr
as you may not want to highlight all of the nodes at the same time:
https://github.com/aysylu/loom/blob/master/src/loom/attr.cljc#L122
Edit: But that function is probably only from UI as it adds fill color which isn't what you'd use in a tree algorithm.