#!/usr/local/bin/perl -w # # David MacKay 2000 # dance.p < file # includer.p file | website.p # # Reads a flat text file containing node specifications. # and connections between nodes # Writes out a diagram of the nodes. Locations are determined by # minimizing an elastic energy. # # Requirements for a quick editor for this system: # Create-new-node - creates node # Link-to-new - creates a link from current node to another node, # and creates that node and prompts for its name. # Accompanied by a 'Done' command that takes you # back to the original 'current' node. (Like a back button) # Link-to-old - creates a link and helps you find the name of the target # # upper case conversion: $name =~ tr/a-z/A-Z/; # $quadratic = 0 ; # whether to use purely quadratic energy functions $gnusize = "0.5,0.5" ; $tol = 0.001 ; $writeduringlearning = 0 ; $T = 10000 ; $period = 20 ; $eta = 0.01 ; # recommend setting this after looking at the maximum strength # and maybe checking the initial gradients $alpha = 0.95 ; $labellocation = "center" ; $boxx = 2 ; # half-size of nodes boxes $boxy = 1 ; # half-size of nodes boxes $doit = 0 ; $o = "d1/g"; $gnu=".gnu" ; $verbose = 1; #$title = "" ; #$abstract = "" ; # $pound="£";$pounds=$pound; sub AUTOLOAD { my $program = $AUTOLOAD; $program =~ s/.*:://; system($program, @_); } # date(); # $thedate=`date` ; # open(DA,"date|"); # $thedate=; # close(DA); $hidden = "hidden" ; $color="color" ; $unnamednode = "unnamednode" ; $BeginObject = "" ; $EndObject = "" ; $BeginObject = "" ; $EndObject = "" ; $nohead="nohead" ; $link = "link" ; $level = "level" ; $to = "to" ; $defaultcolor = 6 ; $defaultcolorl = 3 ; $defaultto = 1 ; $defaultlevel = 1 ; $strength = "strength" ; $bumpstrength = 0.1 ; # this gets scaled down by box size later. $bumpdistx = 2.0 ; $bumpdisty = 3.0 ; $defaultstrength = 0.04 ; # determines the length at which things stop being quadratic, 1/sqrt(strength) $length = "length" ; $defaultlength = 10.0 ; $at = "at" ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; ## Read definitions from file eval "\$$1=\$2" while (defined($_ = <>)) && /^(\w+)=(.*)/ ; # should ensure that this match is a minimal one? # blank line, or any line that is not an equality, causes move to next item # ideally, should be able to skip over comments! eg