From: Tara L Andrews Date: Tue, 12 Jun 2012 11:25:41 +0000 (+0200) Subject: allow creation and SVG rendering of nonlinear graphs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1ff82d4f33cfde715c3f06f4e7b6735ad389745c;p=scpubgit%2Fstemmatology.git allow creation and SVG rendering of nonlinear graphs --- diff --git a/lib/Text/Tradition/Collation.pm b/lib/Text/Tradition/Collation.pm index fcdd1ff..855cd6d 100644 --- a/lib/Text/Tradition/Collation.pm +++ b/lib/Text/Tradition/Collation.pm @@ -560,7 +560,8 @@ sub as_svg { throw( "Need GraphViz installed to output SVG" ) unless File::Which::which( 'dot' ); my $want_subgraph = exists $opts->{'from'} || exists $opts->{'to'}; - $self->calculate_ranks() unless( $self->_graphcalc_done || $opts->{'nocalc'} ); + $self->calculate_ranks() + unless( $self->_graphcalc_done || $opts->{'nocalc'} || !$self->linear ); if( !$self->has_cached_svg || $opts->{'recalc'} || $want_subgraph ) { my @cmd = qw/dot -Tsvg/; my( $svg, $err ); @@ -817,6 +818,7 @@ sub _path_display_label { # See if we are in a majority situation. my $maj = scalar( $self->tradition->witnesses ) * 0.6; + $maj = $maj > 5 ? $maj : 5; if( scalar keys %wits > $maj ) { unshift( @disp_ac, 'majority' ); return join( ', ', @disp_ac ); diff --git a/lib/Text/Tradition/Parser/CollateX.pm b/lib/Text/Tradition/Parser/CollateX.pm index 3521d9f..628e672 100644 --- a/lib/Text/Tradition/Parser/CollateX.pm +++ b/lib/Text/Tradition/Parser/CollateX.pm @@ -132,13 +132,18 @@ sub parse { $collation->add_path( $from->{$IDKEY}, $to->{$IDKEY}, $wit ); } } else { # type 'relationship' - $collation->add_relationship( $from->{$IDKEY}, $to->{$IDKEY}, - { 'type' => 'transposition' } ); + if( $collation->linear ) { + $collation->add_relationship( $from->{$IDKEY}, $to->{$IDKEY}, + { 'type' => 'transposition' } ); + } else { + $collation->merge_readings( $from->{$IDKEY}, $to->{$IDKEY} ); + } } } # Rank the readings. - $collation->calculate_common_readings(); # will implicitly rank + $collation->calculate_common_readings() + if $collation->linear; # will implicitly rank # Save the text for each witness so that we can ensure consistency # later on