(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 #{}}(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(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)(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}cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |