Strongly Connected Components (ColdFusion)

In an Algorithms class in college, I was given the homework assignment of writing the "Strongly Connected Components" algorithm. I originally wrote it in C++, but that implementation has (at least for now) been lost to the sands of time.


Description of the algorithm

A few years later, I had learned ColdFusion, and rewrote it in that language (you know, for fun). The source code is attached at the bottom of this page (scc.zip), and some example screenshots of the usage follows.

<cf_scc 
bCreateAdjacencyMatrix = "Yes"
nNodes = "12"
nEdgeDensity = ".18"
bShowAdjacencyMatrix = "Yes"
r_aAdjacencyMatrixDFS = "aFirstDFS"
bShowTransposeMatrix = "Yes"
r_aTransposeMatrixDFS = "aSecondDFS"
r_aSCCs = "aStronglyConnectedComponents">

<hr>

Strongly Connected Components:<br>
  <cfloop from="1" to="#arraylen(aStronglyConnectedComponents)#" index="j">
    <td><cfoutput>#aStronglyConnectedComponents[j]#<Br></cfoutput></td>
  </cfloop>


The (randomly generated) adjacency matrix in a sample run:



The transposed Matrix:



The Results from the cf tag usage (screenshot from browser window). It still works!


A visual representation of the graph (common colors indicate the strongly connected components)



Comments