TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Color Flood: Wilson's Algorithm

111 pointsby dsilverabout 11 years ago

11 comments

sltkrabout 11 years ago
That code does NOT implement Prim&#x27;s algorithm on a graph with randomly-weighted edges. Instead it just does a randomized breadth-first search of the area (starting from the corner), which is the same algorithm used for colouring, which is why the radial pattern occurs.<p>For a randomized spanning tree, edges should be generated with a random weight, and Prim&#x27;s algorithm extracts them from the frontier ordered by weight. This creates a very different tree structure that is much more similar to the uniform spanning tree generated by Wilson&#x27;s algorithm.<p>(This comment is based on the code from this page: <a href="http://bl.ocks.org/mbostock/11159599" rel="nofollow">http:&#x2F;&#x2F;bl.ocks.org&#x2F;mbostock&#x2F;11159599</a>)
评论 #7660417 未加载
robinhoustonabout 11 years ago
Here’s my version of this from last year: <a href="http://bl.ocks.org/robinhouston/6027749" rel="nofollow">http:&#x2F;&#x2F;bl.ocks.org&#x2F;robinhouston&#x2F;6027749</a>
tripzilchabout 11 years ago
Looks cool. The article could use a bit more explanation of what exactly I&#x27;m looking at.<p>Is this is a flood-fill algorithm?<p>Cause what I remember from back in the day when you could still watch MS Paint do the flood fill, a more efficient version fills out horizontal spans all at once, instead of growing like an ink blot.<p>But it looks cool.<p><i>EDIT:</i> maybe this is one of those &quot;use the entire RGB colour space&quot; type of renderings? (see <a href="http://allrgb.com" rel="nofollow">http:&#x2F;&#x2F;allrgb.com</a> )
评论 #7658882 未加载
评论 #7659020 未加载
nlyabout 11 years ago
Warning for the link to Prim&#x27;s Algorithm: it&#x27;s a beast and will make FF fairly unresponsive.
评论 #7659350 未加载
评论 #7659430 未加载
tantalorabout 11 years ago
You could use an transferable typed array buffer instead of copying an array of integers from the worker thread. Looks like the array is under 4mb, so copying doesn&#x27;t take very long, and you only do it once, but if you&#x27;re going to use a worker you might as well.<p><a href="http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast" rel="nofollow">http:&#x2F;&#x2F;updates.html5rocks.com&#x2F;2011&#x2F;12&#x2F;Transferable-Objects-L...</a>
santaclausabout 11 years ago
It would be cool to visualize the depth with a colormap that makes it visually possible to compare depths, e.g. Matlab&#x27;s Hot. HSV colormaps are pretty but make direct visual comparisons difficult [1].<p>[1] <a href="http://people.renci.org/~borland/pdfs/RainbowColorMap_VisViewpoints.pdf" rel="nofollow">http:&#x2F;&#x2F;people.renci.org&#x2F;~borland&#x2F;pdfs&#x2F;RainbowColorMap_VisVie...</a>
评论 #7660866 未加载
rectangletangleabout 11 years ago
I&#x27;m not quite sure exactly what I&#x27;m looking at, but it looks cool as hell.
mrcactu5about 11 years ago
the point of Wilson&#x27;s algorithm is that each spanning is equally likely.<p>Each tree is selected uniformly amoug the HUGE set of possible spanning trees of this graph.<p>The color patterns in this algorithm vs. Prim algorithm are very different. Unlike Prim algorithm, this pattern is random and has a fractal structure.<p>Is there a good reason a programmer might need each UST to be equally likely?
hcarvalhoalvesabout 11 years ago
I&#x27;ve noticed it stops filling the canvas when I switch tabs, why is that?
goshxabout 11 years ago
This is beautiful. I want to hang it on my wall :)
cwmmaabout 11 years ago
I love mike bostock&#x27;s stuff, but his code often makes me feel sorry for whoever has to deal with his code after him<p><pre><code> &#x2F;&#x2F; Pick a location that’s not yet in the maze (if any). do if ((index0 = remaining.pop()) == null) return true; while (cells[index0] &gt;= 0); &#x2F;&#x2F; Perform a random walk starting at this location, previous[index0] = index0; walk: while (true) { i = index0 % width; j = index0 &#x2F; width | 0; &#x2F;&#x2F; picking a legal random direction at each step. direction = Math.random() * 4 | 0; if (direction === 0) { if (j &lt;= 0) continue walk; --j; } else if (direction === 1) { if (j &gt;= height - 1) continue walk; ++j; } else if (direction === 2) { if (i &lt;= 0) continue walk; --i; } else { if (i &gt;= width - 1) continue walk; ++i; } </code></pre> note the braceless do while and the labeled jump statements
评论 #7660344 未加载
评论 #7660737 未加载