Commit 9c02b51b authored by Mac Newbold's avatar Mac Newbold
Browse files

Fix some bit rot, add in some support for neato graphing.

parent 13381879
......@@ -2,7 +2,7 @@
if ($#ARGV >= 1 || $#ARGV < 0) {
#Help mode
print "Usage: showgraph [display]\n";
print "Usage: schemagraph [output]\n";
print "\n";
print "This shows a graph of the relations in the Testbed Database.\n";
print "Fields or columns are shown as ellipses, and entities or tables\n";
......@@ -39,12 +39,14 @@ my $date = &ctime(time);
$date =~ s/[ \t]+/ /;
$date =~ s/\n//;
my $filename="mygraph";
my $filename="/tmp/showgraph$$";
my $filename2="/tmp/showgraphneato$$";
open(TMP,">$filename");
open(TMPN,">$filename2");
print TMP "graph: {\n orientation: left_to_right\n".
" title: \"Testbed Database Relational Graph - ".$date."\"\n";
print TMP " height: 1000\n width: 500\n";
print TMP " height: 1000\n width: 500\n";
print TMP " priority_phase: yes\n straight_phase: yes\n";
print TMP " arrowmode: fixed\n";
......@@ -55,6 +57,8 @@ print TMP " display_edge_labels: yes\n scaling: 0.37\n";
print TMP " crossingweight: medianbary\n splines: yes\n";
#print TMP " crossingweight: barymedian\n splines: yes\n";
print TMPN "graph G {\n";
my $sth ="";
my $cmd ="";
my @data=();
......@@ -64,6 +68,7 @@ my $col ="";
my @tables=();
my %tablecols=();
my @tablelist =();
my %forkeys=();
foreach $tbl ( @tbls ) {
push(@tablelist,$tbl);
......@@ -74,11 +79,17 @@ foreach $tbl ( @tbls ) {
$col =~ s/[0-9\-]+$//;
if (!defined($tablecols{$col})) {
$tablecols{$col}=$tbl;
print TMP " node: { title: \"$col\" shape: ellipse }\n";
#print TMP " node: { title: \"$col\" shape: ellipse }\n";
#print TMPN "{node [label=\"$col\", color=skyblue, shape=ellipse] $col}\n";
print " Found $col\n" if $v;
} else {
if (!($tablecols{$col} =~ /^$tbl\b|\.$tbl\.|\.$tbl$/) ) {
$tablecols{$col}.=".".$tbl;
if (!defined($forkeys{$col})) {
print TMP " node: { title: \"$col\" shape: ellipse }\n";
print TMPN "{node [label=\"$col\", color=skyblue, shape=ellipse] $col}\n";
}
$forkeys{$col}=1;
print " Linked $col\n" if $v;
} #else { print STDERR "It was in there"; }
}
......@@ -87,29 +98,36 @@ foreach $tbl ( @tbls ) {
}
foreach $tbl ( sort @tablelist) {
print TMP " node: { title: \"$tbl\" }\n";
print TMP " node: { title: \"table_$tbl\" }\n";
print TMPN "{node [label=\"table_$tbl\", color=green, shape=box] table_$tbl}\n";
}
foreach $col ( sort keys %tablecols) {
@tables= sort split('\.',$tablecols{$col});
foreach $tbl (sort @tables) {
if (@tables < 2 ||
$tbl=~/^delta_|proj_|dela|rel|nodes|log|exper|res|part|int/i ) {
print TMP " edge: { sourcename: \"$col\" ".
"targetname: \"$tbl\" }\n";
} else {
print TMP " edge: { sourcename: \"$tbl\" ".
"targetname: \"$col\" }\n";
if (defined($forkeys{$col}) && $forkeys{$col}==1) {
print TMPN "$col -- table_$tbl [label=\"\"];\n";
if (@tables < 2 ||
$tbl=~/^delta_|proj_|dela|rel|nodes|log|exper|res|part|int/i ) {
print TMP " edge: { sourcename: \"$col\" ".
"targetname: \"table_$tbl\" }\n";
} else {
print TMP " edge: { sourcename: \"table_$tbl\" ".
"targetname: \"$col\" }\n";
}
}
}
}
print TMP "}\n";
close TMP;
print TMPN "}\n";
close TMPN;
if ($display ne "") {
system("/usr/local/bin/xvcg -silent -display $display $filename");
system("/usr/X11R6/bin/xvcg -silent -display $display $filename");
} else {
system("/usr/local/bin/xvcg -silent $filename");
system("/usr/X11R6/bin/xvcg -silent $filename");
}
exec "/bin/rm $filename";
#exec "/bin/rm $filename";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment