2 # Take a tree described by weighted edges (on stdin), producing
3 # a png render (on stdout). Uses a text file taken as a parameter
4 # for labelling the nodes.
9 open my $f, "'"$1"'" or die "$!";
10 while (<$f>) { chomp; push @l, $_; }
12 print "graph philo {";
14 chomp; my ($w, $a, $b) = split / /;
15 my $la = $a < 0 ? "$a" : $l[$a];
16 my $lb = $b < 0 ? "$b" : $l[$b];
17 printf "%s -- %s [w=%f, label=\"%.3f\"]\n", $la, $lb, $w, $w;