Skip to content

Commit

Permalink
Deploy docs from e3400fe
Browse files Browse the repository at this point in the history
Soumik Sarkar: Add source for tree reroot fold (#67)
  • Loading branch information
meooow25 committed Feb 25, 2024
1 parent 6972076 commit d06894d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
3 changes: 2 additions & 1 deletion docs/RerootFold.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>RerootFold</title><link href="linuwial.css" rel="stylesheet" type="text/css" title="Linuwial" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script type="text/x-mathjax-config">MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><span class="caption">haccepted-0.1.0.0: Data structures and algorithms</span><ul class="links" id="page-menu"><li><a href="src/RerootFold.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">RerootFold</p></div><div id="description"><p class="caption">Description</p><div class="doc"><h2>Tree reroot fold</h2><p>Folds of a tree with every node as root.
Known as &quot;tree rerooting DP&quot;, among other names.</p><p>Recall that Data.Tree has foldTree :: (a -&gt; [c] -&gt; c) -&gt; Tree a -&gt; c. foldReroot is similar but
requires (b -&gt; c -&gt; b) and b to perform strict folds over [c].</p><p>g :: b -&gt; c -&gt; b must be commutative, in the sense that
(b <code>g</code> c1) <code>g</code> c2 = (b <code>g</code> c2) <code>g</code> c1</p><p>Sources:</p><ul><li>Informal discussions. I am unable to find a good published source for this technique :(</li></ul></div></div><div id="synopsis"><details id="syn"><summary>Synopsis</summary><ul class="details-toggle" data-details-id="syn"><li class="src short"><a href="#v:foldReroot">foldReroot</a> :: (a -&gt; b -&gt; c) -&gt; (b -&gt; c -&gt; b) -&gt; b -&gt; <a href="https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Tree.html#t:Tree" title="Data.Tree">Tree</a> a -&gt; <a href="https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Tree.html#t:Tree" title="Data.Tree">Tree</a> (a, c)</li></ul></details></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:foldReroot" class="def">foldReroot</a> :: (a -&gt; b -&gt; c) -&gt; (b -&gt; c -&gt; b) -&gt; b -&gt; <a href="https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Tree.html#t:Tree" title="Data.Tree">Tree</a> a -&gt; <a href="https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Tree.html#t:Tree" title="Data.Tree">Tree</a> (a, c) <a href="src/RerootFold.html#foldReroot" class="link">Source</a> <a href="#v:foldReroot" class="selflink">#</a></p><div class="doc"><p>Returns the same tree with each vertex accompanied by the fold of the tree if that vertex is made
(b <code>g</code> c1) <code>g</code> c2 = (b <code>g</code> c2) <code>g</code> c1</p><p>Sources:</p><ul><li>pajenegod, &quot;The Ultimate Reroot Template&quot;
<a href="https://codeforces.com/blog/entry/124286">https://codeforces.com/blog/entry/124286</a></li></ul></div></div><div id="synopsis"><details id="syn"><summary>Synopsis</summary><ul class="details-toggle" data-details-id="syn"><li class="src short"><a href="#v:foldReroot">foldReroot</a> :: (a -&gt; b -&gt; c) -&gt; (b -&gt; c -&gt; b) -&gt; b -&gt; <a href="https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Tree.html#t:Tree" title="Data.Tree">Tree</a> a -&gt; <a href="https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Tree.html#t:Tree" title="Data.Tree">Tree</a> (a, c)</li></ul></details></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:foldReroot" class="def">foldReroot</a> :: (a -&gt; b -&gt; c) -&gt; (b -&gt; c -&gt; b) -&gt; b -&gt; <a href="https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Tree.html#t:Tree" title="Data.Tree">Tree</a> a -&gt; <a href="https://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Tree.html#t:Tree" title="Data.Tree">Tree</a> (a, c) <a href="src/RerootFold.html#foldReroot" class="link">Source</a> <a href="#v:foldReroot" class="selflink">#</a></p><div class="doc"><p>Returns the same tree with each vertex accompanied by the fold of the tree if that vertex is made
the root of the tree. f is called O(n) times. g is called O(n log n) times.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.24.0</p></div></body></html>
4 changes: 2 additions & 2 deletions docs/haccepted.txt
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,8 @@ seqToGraph :: Bounds -> [Vertex] -> Graph
-- Sources:
--
-- <ul>
-- <li>Informal discussions. I am unable to find a good published source
-- for this technique :(</li>
-- <li>pajenegod, "The Ultimate Reroot Template"
-- <a>https://codeforces.com/blog/entry/124286</a></li>
-- </ul>
module RerootFold

Expand Down
Loading

0 comments on commit d06894d

Please sign in to comment.