Merge branch 'master' of github.com:tla/stemmatology
[scpubgit/stemmatology.git] / lib / Text / Tradition / Collation.pm
index b53e05c..2b5dbeb 100644 (file)
@@ -27,6 +27,7 @@ has 'relations' => (
        handles => {
                relationships => 'relationships',
                related_readings => 'related_readings',
+               del_relationship => 'del_relationship',
        },
        writer => '_set_relations',
        );
@@ -448,7 +449,8 @@ See as_dot for a list of options.
 
 sub as_svg {
     my( $self, $opts ) = @_;
-    if( !$self->has_cached_svg || $opts->{'recalc'} ) {        
+    my $want_subgraph = exists $opts->{'from'} || exists $opts->{'to'};
+    if( !$self->has_cached_svg || $opts->{'recalc'}    || $want_subgraph ) {        
                my @cmd = qw/dot -Tsvg/;
                my( $svg, $err );
                my $dotfile = File::Temp->new();
@@ -458,9 +460,12 @@ sub as_svg {
                print $dotfile $self->as_dot( $opts );
                push( @cmd, $dotfile->filename );
                run( \@cmd, ">", binary(), \$svg );
-               $self->cached_svg( decode_utf8( $svg ) );
+               $svg = decode_utf8( $svg );
+               $self->cached_svg( $svg ) unless $want_subgraph;
+               return $svg;
+       } else {
+               return $self->cached_svg;
        }
-       return $self->cached_svg;
 }
 
 
@@ -578,10 +583,10 @@ sub as_dot {
                        
                        # Add the calculated edge weights
                        # if( exists $weighted->{$edge->[0]} 
-#                              && $weighted->{$edge->[0]} eq $edge->[1] ) {
-#                              # $variables->{'color'} = 'red';
-#                              $variables->{'weight'} = 3.0;
-#                      }
+                       #       && $weighted->{$edge->[0]} eq $edge->[1] ) {
+                       #       # $variables->{'color'} = 'red';
+                       #       $variables->{'weight'} = 3.0;
+                       # }
 
                        # EXPERIMENTAL: make edge width reflect no. of witnesses
                        my $extrawidth = scalar( $self->path_witnesses( $edge ) ) * 0.2;