Liking cljdoc? Tell your friends :D

hara.core.base.sort


hierarchical-sortclj

(hierarchical-sort idx)

prunes a hierarchy of descendants into a directed graph

(hierarchical-sort {1 #{2 3 4 5 6} 2 #{3 5 6} 3 #{5 6} 4 #{} 5 #{6} 6 #{}}) => {1 #{4 2} 2 #{3} 3 #{5} 4 #{} 5 #{6} 6 #{}}

prunes a hierarchy of descendants into a directed graph

(hierarchical-sort {1 #{2 3 4 5 6}
                    2 #{3 5 6}
                    3 #{5 6}
                    4 #{}
                    5 #{6}
                    6 #{}})
=> {1 #{4 2}
    2 #{3}
    3 #{5}
    4 #{}
   5 #{6}
    6 #{}}
raw docstring

hierarchical-topclj

(hierarchical-top idx)

find the top node for the hierarchy of descendants

(hierarchical-top {1 #{2 3 4 5 6} 2 #{3 5 6} 3 #{5 6} 4 #{} 5 #{6} 6 #{}}) => 1

find the top node for the hierarchy of descendants

(hierarchical-top 
  {1 #{2 3 4 5 6}
   2 #{3 5 6}
   3 #{5 6}
   4 #{}
   5 #{6}
   6 #{}}) => 1
raw docstring

topological-sortclj

(topological-sort g)
(topological-sort g l s)

sorts a directed graph into its dependency order

(topological-sort {:a #{:b :c}, :b #{:d :e}, :c #{:e :f}, :d #{}, :e #{:f}, :f nil}) => [:f :d :e :b :c :a]

(topological-sort {:a #{:b}, :b #{:a}}) => (throws)

sorts a directed graph into its dependency order

(topological-sort {:a #{:b :c},
                   :b #{:d :e},
                   :c #{:e :f},
                   :d #{},
                   :e #{:f},
                   :f nil})
=> [:f :d :e :b :c :a]

(topological-sort {:a #{:b},
                   :b #{:a}})
=> (throws)
raw docstring

topological-topclj

(topological-top g)

nodes that have no other nodes that are dependent on them (topological-top {:a #{} :b #{:a}}) => #{:b}

nodes that have no other nodes that are dependent on them
(topological-top {:a #{} :b #{:a}})
=> #{:b}
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close