Wiki Vandalism Analysis Visualization

This is an attempt to visualize the data contained on WikiVandalismAnalysis. If you have Perl and GraphViz installed, you should be able to run it.

Here is the perl source code:

    @phasecolors=('pink','palegreen','lightblue','lightcyan','wheat','plum');
    $phase=0;
    print("digraph wikivandalismanalysis\n{\n");
    print("graph [overlap=ortho,splines=true];\n");
    print("node [fontname=Helvetica,fontsize=10,shape=box,style=filled,width=.4,height=.2];\n");
    while($line=<stdin>)
    {
        $line=~/'{6}/g;
        if($line=~/^Phase\s[\w\d]+:/)
        {
            $phase++;
        }
        if($line=~/^\t\d+\s.*(.+).+\n?$/)
        {
            $name=trimwhitespace($1);
            if($seenalready{$name})
            {
                print stderr ("$name is defined multiple times!\n");
            }
            else
            {
                $seenalready{$name}=true;
            }
            $color=$phasecolors[$phase-1];
            print("\"$name\" [fillcolor=\"$color\",label=\"$name\"]\n");
            if($line=~/\(leads to:\s([^\)]+)\)/)
            {
                @causes=split(/,/,$1);
                foreach $cause (@causes)
                {
                    $cause=trimwhitespace($cause);
                    print("\"$name\" -> \"$cause\";\n");
                }
            }
            if($line=~/\(requires:\s([^\)]+)\)/)
            {
                @causes=split(/,/,$1);
                foreach $cause (@causes)
                {
                    $cause=trimwhitespace($cause);
                    print("\"$cause\" -> \"$name\" [style=dashed];\n");
                }
            }
        }
    }
    print("}\n");
    sub trimwhitespace($)
    {
        my $string = shift;
        $string =~ s/^\s+//;
        $string =~ s/\s+$//;
        return $string;
    }
To use this script, run the following commands:
 perl makegraph.pl < WikiVandalismAnalysis.txt | neato -Tpng > WikiVandalismAnalysis_neato.png
 perl makegraph.pl < WikiVandalismAnalysis.txt | dot -Tpng > WikiVandalismAnalysis_dot.png
 perl makegraph.pl < WikiVandalismAnalysis.txt | twopi -Tpng > WikiVandalismAnalysis_twopi.png
Examine the three resultant images. Depending on the phase of the moon, one will tend to look better than the others. Pick the one you like best and upload it to your favorite image host service (try http://imageshack.us/), and then update the image link on WikiVandalismAnalysis to point to the hosted image.

I am by no means a Perl or GraphViz guru, so I'm sure this can be improved. (In fact, I am such a non-guru with both of these tools that it is depressing how long it took me to accomplish this. :-) )

-- MichaelSparks


EditText of this page (last edited March 14, 2005) or FindPage with title or text search