Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base: 9700f337d5
...
compare: ac18538185
  • 11 commits
  • 17 files changed
  • 0 commit comments
  • 1 contributor
74 ChangeLog
View
@@ -1,74 +0,0 @@
-
- ChangeLog for Graph-ReadWrite
-
-2.00 2005-jan-02 neilb
- - made the changes needed to work with version 0.5 of Graph classes
- - patch to Graph::Reader::Dot from Mark Hillebrand.
- - fixed warnings "Using a hash as a reference is deprecated"
- - added support for new Dot attributes to Graph::Reader::Dot
- - node ids are now quoted in Graph::Writer::Dot,
- which means you can safely have space, ':', '-', and other
- interesting characters in node ids.
-
-1.06 2002-jul-09 neilb
-
- Added XML::Parser and XML::Writer as dependencies in Makefile.PL.
- This was prompted by looking at testers.cpan.org, which has
- this distribution as failing.
-
-1.05 2002-mar-20 neilb
-
- Graph::Writer::VCG - common attributes (label, color, and
- text color) weren't supported on edges.
- Bug and fix reported by Alexandre Cherif.
-
-1.05 2002-jan-20 neilb
-
- Added a basic test-suite.
-
- Commented out debugging output in the HTK Writer. Sorry Phil!
-
-1.04 2001-nov-11 neilb
-
- Added Graph::Reader::Dot, a reader for the Dot format
- contributed by Mark Hillebrand.
-
- Fixed a bug in Graph::Reader::XML, found by Mark Hillebrand.
- The reader would only cope with a single <attribute> element
- inside each graph, node or edge element.
-
- Changed contact email address to neil@bowers.com
-
-1.03
-
- Added reader and writer classes for HTK lattice files.
-
-1.02
- Fixed a bug in the XML writer module - the way it was using
- XML::Writer caused STDOUT to be closed after you've written
- a graph. I consider it a bug in XML::Writer, but I was able
- to change the way Graph::Writer::XML uses that module.
-
- Basically it just means that we construct a new instance
- of XML::Writer every time we write out a graph. For most
- uses, this won't be a problem, but you'd notice a hit if
- you were creating the writer and then writing a lot of graphs.
-
- This was noticed by Mike Hayward <hayward@loup.net>
-
-1.01
-
- Added support for URL attribute on nodes in Dot.
-
- Added support for almost all attributes understood by VCG.
-
- Added a rough cut at a Writer class for daVinci:
- Graph::Writer::daVinci
-
-1.00 feb 2001 neilb
-
- Initial release - has baseclass for Reader and Writer classes.
-
- Reader and Writer for simple XML format.
-
- Writers for Dot and VCG formats.
81 Changes
View
@@ -0,0 +1,81 @@
+Revision history for perl distribution Graph-ReadWrite
+
+2.01 2012-02-12
+
+ - Fixed RT bug #39792: trying to call method set_graph_attribute()
+ on Graph::Reader::XML, which should have been set_attribute().
+ - changed calls to File::Compare::compare() to hopefully cope with
+ EOL differences between Windows and Unix. Reported by Philip Potter,
+ and fix noted by Max
+ - Ensured all modules were use'ing strict and warnings. Fixed warnings :-)
+ - Cleaned up formatting of all modules
+ - renamed ChangeLog to Changes and reformatted as per CPAN::Changes::Spec
+
+2.00 2005-01-02
+
+ - made the changes needed to work with version 0.5 of Graph classes
+ - patch to Graph::Reader::Dot from Mark Hillebrand.
+ - fixed warnings "Using a hash as a reference is deprecated"
+ - added support for new Dot attributes to Graph::Reader::Dot
+ - node ids are now quoted in Graph::Writer::Dot,
+ which means you can safely have space, ':', '-', and other
+ interesting characters in node ids.
+
+1.07 2002-07-09
+
+ - Added XML::Parser and XML::Writer as dependencies in Makefile.PL.
+ This was prompted by looking at testers.cpan.org, which has
+ this distribution as failing.
+
+1.06 2002-03-20
+
+ - Graph::Writer::VCG - common attributes (label, color, and
+ text color) weren't supported on edges.
+ Bug and fix reported by Alexandre Cherif.
+
+1.05 2002-01-20
+
+ - Added a basic test-suite.
+ - Commented out debugging output in the HTK Writer. Sorry Phil!
+
+1.04 2001-11-11
+
+ - Added Graph::Reader::Dot, a reader for the Dot format
+ contributed by Mark Hillebrand.
+
+ - Fixed a bug in Graph::Reader::XML, found by Mark Hillebrand.
+ The reader would only cope with a single <attribute> element
+ inside each graph, node or edge element.
+
+ - Changed contact email address to neil at bowers dot com
+
+1.03
+
+ - Added reader and writer classes for HTK lattice files.
+
+1.02
+
+ - Fixed a bug in the XML writer module - the way it was using
+ XML::Writer caused STDOUT to be closed after you've written
+ a graph. I consider it a bug in XML::Writer, but I was able
+ to change the way Graph::Writer::XML uses that module.
+
+ Basically it just means that we construct a new instance
+ of XML::Writer every time we write out a graph. For most
+ uses, this won't be a problem, but you'd notice a hit if
+ you were creating the writer and then writing a lot of graphs.
+
+ This was noticed by Mike Hayward <hayward@loup.net>
+
+1.01
+
+ - Added support for URL attribute on nodes in Dot.
+ - Added support for almost all attributes understood by VCG.
+ - Added a rough cut at a Writer class for daVinci: Graph::Writer::daVinci
+
+1.00 2001-02
+
+ - Initial release - has baseclass for Reader and Writer classes.
+ - Reader and Writer for simple XML format.
+ - Writers for Dot and VCG formats.
+
3  MANIFEST
View
@@ -2,7 +2,7 @@ Makefile.PL
MANIFEST
README
TODO
-ChangeLog
+Changes
lib/Graph/Writer.pm
lib/Graph/Writer/Dot.pm
lib/Graph/Writer/XML.pm
@@ -21,4 +21,3 @@ t/data/simple.xml
t/data/simple.dot
t/data/simple.htk
t/data/simple.vcg
-META.yml Module meta-data (added by MakeMaker)
14 META.yml
View
@@ -1,14 +0,0 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
-name: Graph-ReadWrite
-version: 2.00
-version_from:
-installdirs: site
-requires:
- Graph: 0.5
- IO::File: 0
- XML::Parser: 0
- XML::Writer: 0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
12 Makefile.PL
View
@@ -1,8 +1,6 @@
#
# Makefile.PL for Graph-ReadWrite
#
-# $Id: Makefile.PL,v 1.2 2005/01/02 19:06:58 neilb Exp $
-#
use ExtUtils::MakeMaker;
@@ -10,12 +8,12 @@ use ExtUtils::MakeMaker;
&WriteMakefile(
NAME => 'Graph-ReadWrite',
DISTNAME => 'Graph-ReadWrite',
- VERSION => '2.00',
+ VERSION => '2.01',
PREREQ_PM => {
- 'IO::File' => 0,
- 'Graph' => 0.5,
- 'XML::Parser' => 0,
- 'XML::Writer' => 0,
+ 'IO::File' => 0,
+ 'Graph' => 0.5,
+ 'XML::Parser' => 0,
+ 'XML::Writer' => 0,
},
dist => {COMPRESS => 'gzip', SUFFIX => 'gz'},
);
5 README
View
@@ -1,11 +1,11 @@
Graph-ReadWrite
- 2.00
+ 2.01
This is a collection of perl classes for reading and writing
directed graphs in a variety of file formats. The graphs are
represented in Perl using Jarkko Hietaniemi's Graph classes.
-Version 2.0 of this distribution works with version 0.5 and
+Version 2+ of this distribution works with version 0.5 and
later of the Graph distribution.
There are two base classes:
@@ -65,4 +65,3 @@ you may get a warning about an undefined value from one of the tests.
Bugs, suggestions, and new readers and writers will be gratefully received.
Neil Bowers <neil@bowers.com>
-$Id: README,v 1.2 2005/01/02 19:00:08 neilb Exp $
104 lib/Graph/Reader.pm
View
@@ -1,14 +1,12 @@
#
# Graph::Reader - perl base class for Graph file format readers
#
-# $Id: Reader.pm,v 1.3 2005/01/02 19:01:06 neilb Exp $
-#
package Graph::Reader;
use strict;
+use warnings;
-use vars qw($VERSION);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
+our $VERSION = '2.01';
use IO::File;
use Graph;
@@ -65,18 +63,18 @@ sub read_graph
if (ref $filename)
{
- $self->_read_graph($graph, $filename);
+ $self->_read_graph($graph, $filename);
}
else
{
- $FILE = IO::File->new("< $filename");
- if (not defined $FILE)
- {
- warn "couldn't read from $filename: $!\n";
- return 0;
- }
- $self->_read_graph($graph, $FILE);
- $FILE->close();
+ $FILE = IO::File->new("< $filename");
+ if (not defined $FILE)
+ {
+ warn "couldn't read from $filename: $!\n";
+ return 0;
+ }
+ $self->_read_graph($graph, $FILE);
+ $FILE->close();
}
return $graph;
@@ -92,17 +90,17 @@ Graph::Reader - base class for Graph file format readers
=head1 SYNOPSIS
- package Graph::Reader::MyFormat;
- use Graph::Reader;
- use vars qw(@ISA);
- @ISA = qw(Graph::Reader);
+ package Graph::Reader::MyFormat;
+ use Graph::Reader;
+ use vars qw(@ISA);
+ @ISA = qw(Graph::Reader);
- sub _read_graph
- {
- my ($self, $graph, $FILE) = @_;
-
- # read $FILE and populate $graph
- }
+ sub _read_graph
+ {
+ my ($self, $graph, $FILE) = @_;
+
+ # read $FILE and populate $graph
+ }
=head1 DESCRIPTION
@@ -124,7 +122,7 @@ is a virtual method, or whatever the correct lingo is.
You're not meant to call this on the base class,
it is inherited by the subclasses. Ie if you do something like:
- $reader = Graph::Reader->new();
+ $reader = Graph::Reader->new();
It will throw an exception.
@@ -132,7 +130,7 @@ It will throw an exception.
Read a graph from the specified file:
- $graph = $reader->read_graph($file);
+ $graph = $reader->read_graph($file);
The C<$file> argument can either be a filename,
or a filehandle for a previously opened file.
@@ -144,26 +142,26 @@ which subclasses B<Graph::Reader>. For example, suppose
DGF is a directed graph format - create a B<Graph::Reader::DGF> module,
with the following structure:
- package Graph::Reader::DGF;
-
- use Graph::Reader;
- use vars qw(@ISA);
- @ISA = qw(Graph::Reader);
-
- sub _read_graph
- {
- my $self = shift;
- my $graph = shift;
- my $FILE = shift;
-
- while (<$FILE>)
- {
- }
+ package Graph::Reader::DGF;
+
+ use Graph::Reader;
+ use vars qw(@ISA);
+ @ISA = qw(Graph::Reader);
+
+ sub _read_graph
+ {
+ my $self = shift;
+ my $graph = shift;
+ my $FILE = shift;
- return 1;
+ while (<$FILE>)
+ {
}
+
+ return 1;
+ }
- 1;
+ 1;
Note the leading underscore on the B<_read_graph()> method.
The base class provides the public method, and invokes the
@@ -175,21 +173,21 @@ which will be invoked by the base class's constructor.
You should invoke the superclass's initialiser as well,
as follows:
- sub _init
- {
- my $self = shift;
+ sub _init
+ {
+ my $self = shift;
- $self->SUPER::_init();
+ $self->SUPER::_init();
- # your initialisation here
- }
+ # your initialisation here
+ }
Someone can then use your class as follows:
- use Graph::Reader::DGF;
-
- $reader = Graph::Reader::DGF->new();
- $graph = $reader->read_graph('foo.dgf');
+ use Graph::Reader::DGF;
+
+ $reader = Graph::Reader::DGF->new();
+ $graph = $reader->read_graph('foo.dgf');
=head1 SEE ALSO
@@ -222,7 +220,7 @@ Neil Bowers E<lt>neil@bowers.comE<gt>
=head1 COPYRIGHT
-Copyright (c) 2001-2005, Neil Bowers. All rights reserved.
+Copyright (c) 2001-2012, Neil Bowers. All rights reserved.
Copyright (c) 2001, Canon Research Centre Europe. All rights reserved.
This script is free software; you can redistribute it and/or modify
244 lib/Graph/Reader/HTK.pm
View
@@ -1,15 +1,15 @@
#
# Graph::Reader::HTK - perl module for reading an HTK lattice into a Graph
#
-# $Id: HTK.pm,v 1.3 2005/01/02 19:03:14 neilb Exp $
-#
package Graph::Reader::HTK;
-use Graph::Reader;
+use strict;
+use warnings;
+
+use parent 'Graph::Reader';
use Carp;
-use vars qw(@ISA $VERSION);
-@ISA = qw(Graph::Reader);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
+
+our $VERSION = '2.01';
my %node_attributes =
(
@@ -62,117 +62,127 @@ sub _read_graph
my $to;
my $weight;
my ($an, $av);
+ my $node_num;
+ my $link;
while (<$FILE>)
{
- chop;
-
- #---------------------------------------------------------------
- # ignore version line
- #---------------------------------------------------------------
- if (/^\s*(V|VERSION)\s*=\s*(\S+)/) {
- $graph->set_graph_attribute('HTK_VERSION', $2);
- next;
- }
-
- if (/^\s*(base|lmname|lmscale|wdpenalty)\s*=\s*(\S+)/)
- {
- # print STDERR "Setting graph attribute $1 to $2\n";
- $graph->set_graph_attribute($1, ''.$2);
- }
-
- #---------------------------------------------------------------
- # line which says how many nodes & links we have
- #---------------------------------------------------------------
- if (/N\s*=\s*(\d+)\s*L\s*=\s*(\d+)/)
- {
- # $NUM_NODES = $1;
- # $NUM_LINKS = $2;
- next;
- }
-
- #---------------------------------------------------------------
- # node definition
- #---------------------------------------------------------------
- if (/^I\s*=\s*(\d+)/mg)
- {
- #---------------------------------------------------------------
- # strip off the fields from the rest of the line
- # and set appropriate attributes
- #---------------------------------------------------------------
- $node_num = "n$1";
- $graph->add_vertex($node_num);
- # print STDERR "Node $node_num:\n";
- while (/\s*(\S+)\s*=\s*(\S+)/mg)
- {
- $an = $1;
- $av = $2;
- if (exists $node_attributes{$an})
- {
- foreach my $a (@{ $node_attributes{$an} })
- {
- # print STDERR " attr $a = $av\n";
- $graph->set_vertex_attribute($node_num, $a, $av);
- }
- } else {
- carp "unknown node field \"$an\" - ignoring\n";
- }
- }
- next;
- }
- elsif (/I\s*=\s*/)
- {
- carp "unexpected format for node line \"$_\" - ignoring\n";
- next;
- }
-
- #---------------------------------------------------------------
- # edge definition
- #---------------------------------------------------------------
- if (/^J\s*=\s*(\d+)/mg)
- {
- my %attr;
-
- $link = $1;
- # print STDERR "Edge $link:\n";
- while (/\s*(\S+)\s*=\s*(\S+)/mg)
- {
- $an = $1;
- $av = $2;
- # print STDERR " field $an = $av\n";
- if (exists $edge_attributes{$an})
- {
- foreach my $a (@{ $edge_attributes{$an} })
- {
- $attr{$a} = $av;
- }
- } else {
- carp "unknown link field \"$an\" - ignoring\n";
- }
- }
-
- if (exists $attr{START} && exists $attr{END}) {
- $from = 'n'.$attr{START};
- $to = 'n'.$attr{END};
- delete $attr{START};
- delete $attr{END};
- } else {
- carp "link on line $. doesn't have START and END - ignoring\n";
- next;
- }
- $graph->add_edge($from, $to);
- foreach $a (keys %attr)
- {
- # print STDERR " attr $a = ", $attr{$a}, "\n";
- $graph->set_edge_attribute($from, $to, $a, $attr{$a});
- }
- }
- elsif (/^J/)
- {
- carp "unexpected format for link line \"$_\" - ignoring\n";
- next;
- }
+ chop;
+
+ #---------------------------------------------------------------
+ # ignore version line
+ #---------------------------------------------------------------
+ if (/^\s*(V|VERSION)\s*=\s*(\S+)/)
+ {
+ $graph->set_graph_attribute('HTK_VERSION', $2);
+ next;
+ }
+
+ if (/^\s*(base|lmname|lmscale|wdpenalty)\s*=\s*(\S+)/)
+ {
+ # print STDERR "Setting graph attribute $1 to $2\n";
+ $graph->set_graph_attribute($1, ''.$2);
+ }
+
+ #---------------------------------------------------------------
+ # line which says how many nodes & links we have
+ #---------------------------------------------------------------
+ if (/N\s*=\s*(\d+)\s*L\s*=\s*(\d+)/)
+ {
+ # $NUM_NODES = $1;
+ # $NUM_LINKS = $2;
+ next;
+ }
+
+ #---------------------------------------------------------------
+ # node definition
+ #---------------------------------------------------------------
+ if (/^I\s*=\s*(\d+)/mg)
+ {
+ #---------------------------------------------------------------
+ # strip off the fields from the rest of the line
+ # and set appropriate attributes
+ #---------------------------------------------------------------
+ $node_num = "n$1";
+ $graph->add_vertex($node_num);
+ # print STDERR "Node $node_num:\n";
+ while (/\s*(\S+)\s*=\s*(\S+)/mg)
+ {
+ $an = $1;
+ $av = $2;
+ if (exists $node_attributes{$an})
+ {
+ foreach my $a (@{ $node_attributes{$an} })
+ {
+ # print STDERR " attr $a = $av\n";
+ $graph->set_vertex_attribute($node_num, $a, $av);
+ }
+ }
+ else
+ {
+ carp "unknown node field \"$an\" - ignoring\n";
+ }
+ }
+ next;
+ }
+ elsif (/I\s*=\s*/)
+ {
+ carp "unexpected format for node line \"$_\" - ignoring\n";
+ next;
+ }
+
+ #---------------------------------------------------------------
+ # edge definition
+ #---------------------------------------------------------------
+ if (/^J\s*=\s*(\d+)/mg)
+ {
+ my %attr;
+
+ $link = $1;
+ # print STDERR "Edge $link:\n";
+ while (/\s*(\S+)\s*=\s*(\S+)/mg)
+ {
+ $an = $1;
+ $av = $2;
+ # print STDERR " field $an = $av\n";
+ if (exists $edge_attributes{$an})
+ {
+ foreach my $a (@{ $edge_attributes{$an} })
+ {
+ $attr{$a} = $av;
+ }
+ }
+ else
+ {
+ carp "unknown link field \"$an\" - ignoring\n";
+ }
+ }
+
+ if (exists $attr{START} && exists $attr{END})
+ {
+ $from = 'n'.$attr{START};
+ $to = 'n'.$attr{END};
+ delete $attr{START};
+ delete $attr{END};
+ }
+ else
+ {
+ carp "link on line $. doesn't have START and END - ignoring\n";
+ next;
+ }
+ $graph->add_edge($from, $to);
+ foreach $a (keys %attr)
+ {
+ # print STDERR " attr $a = ", $attr{$a}, "\n";
+ $graph->set_edge_attribute($from, $to, $a, $attr{$a});
+ }
+ }
+ elsif (/^J/)
+ {
+ carp "unexpected format for link line \"$_\" - ignoring\n";
+ next;
+ }
}
return 1;
@@ -188,10 +198,10 @@ Graph::Reader::HTK - read an HTK lattice in as an instance of Graph
=head1 SYNOPSIS
- use Graph::Reader::HTK;
-
- $reader = Graph::Reader::HTK->new;
- $graph = $reader->read_graph('mylattice.lat');
+ use Graph::Reader::HTK;
+
+ $reader = Graph::Reader::HTK->new;
+ $graph = $reader->read_graph('mylattice.lat');
=head1 DESCRIPTION
65 lib/Graph/Reader/XML.pm
View
@@ -1,19 +1,16 @@
#
# Graph::Reader::XML - perl class for reading directed graphs from XML
#
-# $Id: XML.pm,v 1.3 2005/01/02 19:03:14 neilb Exp $
-#
package Graph::Reader::XML;
use strict;
+use warnings;
-use Graph::Reader;
+use parent 'Graph::Reader';
use Carp;
use XML::Parser;
-use vars qw(@ISA $VERSION);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
-@ISA = qw(Graph::Reader);
+our $VERSION = '2.01';
#=======================================================================
#
@@ -80,32 +77,32 @@ sub handle_start
if ($el eq 'attribute')
{
- if (exists $attr{name} && exists $attr{value})
- {
- $self->set_graph_attribute($attr{name}, $attr{value});
- }
- else
- {
- carp "attribute should have name and value - ignoring\n";
- }
+ if (exists $attr{name} && exists $attr{value})
+ {
+ $self->set_attribute($attr{name}, $attr{value});
+ }
+ else
+ {
+ carp "attribute should have name and value - ignoring\n";
+ }
}
elsif ($el eq 'node')
{
- $graph->add_vertex($attr{id});
- push(@{$self->{CONTEXT}}, [$el, $attr{id}]);
+ $graph->add_vertex($attr{id});
+ push(@{$self->{CONTEXT}}, [$el, $attr{id}]);
}
elsif ($el eq 'edge')
{
- $graph->add_edge($attr{from}, $attr{to});
- push(@{$self->{CONTEXT}}, [$el, $attr{from}, $attr{to}]);
+ $graph->add_edge($attr{from}, $attr{to});
+ push(@{$self->{CONTEXT}}, [$el, $attr{from}, $attr{to}]);
}
elsif ($el eq 'graph')
{
- push(@{$self->{CONTEXT}}, [$el]);
+ push(@{$self->{CONTEXT}}, [$el]);
}
else
{
- carp "unknown element \"$el\"\n";
+ carp "unknown element \"$el\"\n";
}
}
@@ -142,8 +139,8 @@ sub set_attribute
if (@{$self->{CONTEXT}} == 0)
{
- carp "attribute element with no context - ignoring!\n";
- return;
+ carp "attribute element with no context - ignoring!\n";
+ return;
}
my $graph = $self->{GRAPH};
@@ -151,19 +148,19 @@ sub set_attribute
if ($el eq 'node')
{
- $graph->set_vertex_attribute($args[0], $name, $value);
+ $graph->set_vertex_attribute($args[0], $name, $value);
}
elsif ($el eq 'edge')
{
- $graph->set_edge_attribute($args[0], $args[1], $name, $value);
+ $graph->set_edge_attribute($args[0], $args[1], $name, $value);
}
elsif ($el eq 'graph')
{
- $graph->set_graph_attribute($name, $value);
+ $graph->set_graph_attribute($name, $value);
}
else
{
- carp "unexpected context for attribute\n";
+ carp "unexpected context for attribute\n";
}
}
@@ -175,11 +172,11 @@ Graph::Reader::XML - class for reading a Graph instance from XML
=head1 SYNOPSIS
- use Graph::Reader::XML;
- use Graph;
-
- $reader = Graph::Reader::XML->new();
- $graph = $reader->read_graph('mygraph.xml');
+ use Graph::Reader::XML;
+ use Graph;
+
+ $reader = Graph::Reader::XML->new();
+ $graph = $reader->read_graph('mygraph.xml');
=head1 DESCRIPTION
@@ -200,7 +197,7 @@ which defines the generic interface for Graph reader classes.
Constructor - generate a new reader instance.
- $reader = Graph::Reader::XML->new();
+ $reader = Graph::Reader::XML->new();
This doesn't take any arguments.
@@ -208,7 +205,7 @@ This doesn't take any arguments.
Read a graph from a file:
- $graph = $reader->read_graph( $file );
+ $graph = $reader->read_graph( $file );
The C<$file> argument can be either a filename
or a filehandle of a previously opened file.
@@ -242,7 +239,7 @@ Neil Bowers E<lt>neil@bowers.comE<gt>
=head1 COPYRIGHT
-Copyright (c) 2001-2005, Neil Bowers. All rights reserved.
+Copyright (c) 2001-2012, Neil Bowers. All rights reserved.
Copyright (c) 2001, Canon Research Centre Europe. All rights reserved.
This module is free software; you can redistribute it and/or modify
100 lib/Graph/Writer.pm
View
@@ -1,14 +1,12 @@
#
# Graph::Writer - perl base class for Graph file format writers
#
-# $Id: Writer.pm,v 1.3 2005/01/02 19:01:06 neilb Exp $
-#
package Graph::Writer;
use strict;
+use warnings;
-use vars qw($VERSION);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
+our $VERSION = '2.01';
use IO::File;
@@ -66,18 +64,18 @@ sub write_graph
if (ref $filename)
{
- $self->_write_graph($graph, $filename);
+ $self->_write_graph($graph, $filename);
}
else
{
- my $FILE = IO::File->new("> $filename");
- if (not defined $FILE)
- {
- warn "couldn't write to $filename: $!\n";
- return 0;
- }
- $self->_write_graph($graph, $FILE);
- $FILE->close();
+ my $FILE = IO::File->new("> $filename");
+ if (not defined $FILE)
+ {
+ warn "couldn't write to $filename: $!\n";
+ return 0;
+ }
+ $self->_write_graph($graph, $FILE);
+ $FILE->close();
}
return 1;
@@ -93,17 +91,17 @@ Graph::Writer - base class for Graph file format writers
=head1 SYNOPSIS
- package Graph::Writer::MyFormat;
- use Graph::Writer;
- use vars qw(@ISA);
- @ISA = qw(Graph::Writer);
+ package Graph::Writer::MyFormat;
+ use Graph::Writer;
+ use vars qw(@ISA);
+ @ISA = qw(Graph::Writer);
- sub _write_graph
- {
- my ($self, $graph, $FILE) = @_;
+ sub _write_graph
+ {
+ my ($self, $graph, $FILE) = @_;
- # write $graph to $FILE
- }
+ # write $graph to $FILE
+ }
=head1 DESCRIPTION
@@ -125,7 +123,7 @@ is a virtual method, or whatever the correct lingo is.
You're not meant to call this on the base class,
it is inherited by the subclasses. Ie if you do something like:
- $writer = Graph::Writer->new();
+ $writer = Graph::Writer->new();
It will throw an exception.
@@ -133,7 +131,7 @@ It will throw an exception.
Read a graph from the specified file:
- $graph = $writer->write_graph($file);
+ $graph = $writer->write_graph($file);
The C<$file> argument can either be a filename,
or a filehandle for a previously opened file.
@@ -145,26 +143,26 @@ which subclasses B<Graph::Writer>. For example, suppose
DGF is a directed graph format - create a B<Graph::Writer::DGF> module,
with the following structure:
- package Graph::Writer::DGF;
+ package Graph::Writer::DGF;
- use Graph::Writer;
- use vars qw(@ISA);
- @ISA = qw(Graph::Writer);
-
- sub _write_graph
- {
- my $self = shift;
- my $graph = shift;
- my $FILE = shift;
-
- while (<$FILE>)
- {
- }
+ use Graph::Writer;
+ use vars qw(@ISA);
+ @ISA = qw(Graph::Writer);
+
+ sub _write_graph
+ {
+ my $self = shift;
+ my $graph = shift;
+ my $FILE = shift;
- return 1;
+ while (<$FILE>)
+ {
}
+
+ return 1;
+ }
- 1;
+ 1;
Note the leading underscore on the B<_write_graph()> method.
The base class provides the public method, and invokes the
@@ -176,21 +174,21 @@ which will be invoked by the base class's constructor.
You should invoke the superclass's initialiser as well,
as follows:
- sub _init
- {
- my $self = shift;
+ sub _init
+ {
+ my $self = shift;
- $self->SUPER::_init();
+ $self->SUPER::_init();
- # your initialisation here
- }
+ # your initialisation here
+ }
Someone can then use your class as follows:
- use Graph::Writer::DGF;
-
- $writer = Graph::Writer::DGF->new();
- $writer->write_graph($graph, 'foo.dgf');
+ use Graph::Writer::DGF;
+
+ $writer = Graph::Writer::DGF->new();
+ $writer->write_graph($graph, 'foo.dgf');
=head1 SEE ALSO
@@ -236,7 +234,7 @@ Neil Bowers E<lt>neil@bowers.comE<gt>
=head1 COPYRIGHT
-Copyright (c) 2001-2005, Neil Bowers. All rights reserved.
+Copyright (c) 2001-2012, Neil Bowers. All rights reserved.
Copyright (c) 2001, Canon Research Centre Europe. All rights reserved.
This script is free software; you can redistribute it and/or modify
73 lib/Graph/Writer/Dot.pm
View
@@ -1,16 +1,13 @@
#
# Graph::Writer::Dot - write a directed graph out in Dot format
#
-# $Id: Dot.pm,v 1.3 2005/01/02 19:04:05 neilb Exp $
-#
package Graph::Writer::Dot;
use strict;
+use warnings;
-use Graph::Writer;
-use vars qw(@ISA $VERSION);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
-@ISA = qw(Graph::Writer);
+use parent 'Graph::Writer';
+our $VERSION = '2.01';
#-----------------------------------------------------------------------
# List of valid dot attributes for the entire graph, per node,
@@ -99,11 +96,11 @@ sub _write_graph
@keys = grep(exists $attrref->{$_}, @{$valid_attributes{'graph'}});
if (@keys > 0)
{
- print $FILE " /* graph attributes */\n";
- foreach my $a (@keys)
- {
- print $FILE " $a = \"", $attrref->{$a}, "\";\n";
- }
+ print $FILE " /* graph attributes */\n";
+ foreach my $a (@keys)
+ {
+ print $FILE " $a = \"", $attrref->{$a}, "\";\n";
+ }
}
#-------------------------------------------------------------------
@@ -112,14 +109,15 @@ sub _write_graph
print $FILE "\n /* list of nodes */\n";
foreach $v (sort $graph->vertices)
{
- print $FILE " \"$v\"";
- $attrref = $graph->get_vertex_attributes($v);
- @keys = grep(exists $attrref->{$_}, @{$valid_attributes{'node'}});
- if (@keys > 0)
- {
- print $FILE " [", join(',', map { "$_=\"".$attrref->{$_}."\"" } @keys), "]";
- }
- print $FILE ";\n";
+ print $FILE " \"$v\"";
+ $attrref = $graph->get_vertex_attributes($v);
+ @keys = grep(exists $attrref->{$_}, @{$valid_attributes{'node'}});
+ if (@keys > 0)
+ {
+ print $FILE " [", join(',',
+ map { "$_=\"".$attrref->{$_}."\"" } @keys), "]";
+ }
+ print $FILE ";\n";
}
#-------------------------------------------------------------------
@@ -128,15 +126,16 @@ sub _write_graph
print $FILE "\n /* list of edges */\n";
foreach my $edge (sort _by_vertex $graph->edges)
{
- ($from, $to) = @$edge;
- print $FILE " \"$from\" -> \"$to\"";
- $attrref = $graph->get_edge_attributes($from, $to);
- @keys = grep(exists $attrref->{$_}, @{$valid_attributes{'edge'}});
- if (@keys > 0)
- {
- print $FILE " [", join(',', map { "$_ = \"".$attrref->{$_}."\"" } @keys), "]";
- }
- print $FILE ";\n";
+ ($from, $to) = @$edge;
+ print $FILE " \"$from\" -> \"$to\"";
+ $attrref = $graph->get_edge_attributes($from, $to);
+ @keys = grep(exists $attrref->{$_}, @{$valid_attributes{'edge'}});
+ if (@keys > 0)
+ {
+ print $FILE " [", join(',',
+ map { "$_ = \"".$attrref->{$_}."\"" } @keys), "]";
+ }
+ print $FILE ";\n";
}
#-------------------------------------------------------------------
@@ -164,14 +163,14 @@ Graph::Writer::Dot - write out directed graph in Dot format
=head1 SYNOPSIS
- use Graph;
- use Graph::Writer::Dot;
+ use Graph;
+ use Graph::Writer::Dot;
- $graph = Graph->new();
- # add edges and nodes to the graph
+ $graph = Graph->new();
+ # add edges and nodes to the graph
- $writer = Graph::Writer::Dot->new();
- $writer->write_graph($graph, 'mygraph.dot');
+ $writer = Graph::Writer::Dot->new();
+ $writer->write_graph($graph, 'mygraph.dot');
=head1 DESCRIPTION
@@ -187,7 +186,7 @@ actually a set of classes developed by Jarkko Hietaniemi.
Constructor - generate a new writer instance.
- $writer = Graph::Writer::Dot->new();
+ $writer = Graph::Writer::Dot->new();
This doesn't take any arguments.
@@ -195,7 +194,7 @@ This doesn't take any arguments.
Write a specific graph to a named file:
- $writer->write_graph($graph, $file);
+ $writer->write_graph($graph, $file);
The C<$file> argument can either be a filename,
or a filehandle for a previously opened file.
@@ -231,7 +230,7 @@ Neil Bowers E<lt>neil@bowers.comE<gt>
=head1 COPYRIGHT
-Copyright (c) 2001-2005, Neil Bowers. All rights reserved.
+Copyright (c) 2001-2012, Neil Bowers. All rights reserved.
Copyright (c) 2001, Canon Research Centre Europe. All rights reserved.
This script is free software; you can redistribute it and/or modify
84 lib/Graph/Writer/HTK.pm
View
@@ -1,17 +1,16 @@
#
# Graph::Writer::HTK - perl module for writing a Graph as an HTK lattice
#
-# $Id: HTK.pm,v 1.3 2005/01/02 19:04:05 neilb Exp $
-#
package Graph::Writer::HTK;
+use strict;
+use warnings;
+
#=======================================================================
#=======================================================================
-use Graph::Writer;
-use vars qw(@ISA $VERSION);
-@ISA = qw(Graph::Writer);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
+use parent 'Graph::Writer';
+our $VERSION = '2.01';
my @graph_attributes = qw(base lmname lmscale wdpenalty);
@@ -62,42 +61,43 @@ sub _write_graph
$node_num = 0;
foreach $v (sort $graph->vertices)
{
- $v2n{$v} = $node_num;
- print $FILE "I=$node_num";
- foreach my $field (keys %node_attributes)
- {
- foreach my $attr (@{ $node_attributes{$field} })
- {
- if ($graph->has_vertex_attribute($v, $attr))
- {
- print $FILE " $field=", $graph->get_vertex_attribute($v, $attr);
- last;
- }
- }
- }
- print $FILE "\n";
- ++$node_num;
+ $v2n{$v} = $node_num;
+ print $FILE "I=$node_num";
+ foreach my $field (keys %node_attributes)
+ {
+ foreach my $attr (@{ $node_attributes{$field} })
+ {
+ if ($graph->has_vertex_attribute($v, $attr))
+ {
+ print $FILE " $field=",
+ $graph->get_vertex_attribute($v, $attr);
+ last;
+ }
+ }
+ }
+ print $FILE "\n";
+ ++$node_num;
}
$edge_num = 0;
foreach my $edge (sort _by_vertex $graph->edges)
{
- ($from, $to) = @$edge;
- print $FILE "J=$edge_num S=", $v2n{$from}, " E=", $v2n{$to};
- foreach my $field (keys %edge_attributes)
- {
- foreach my $attr (@{ $edge_attributes{$field} })
- {
- if ($graph->has_edge_attribute($from, $to, $attr))
- {
- print $FILE " $field=",
- $graph->get_vertex_attribute($from, $to, $attr);
- last;
- }
- }
- }
- print $FILE "\n";
- ++$edge_num;
+ ($from, $to) = @$edge;
+ print $FILE "J=$edge_num S=", $v2n{$from}, " E=", $v2n{$to};
+ foreach my $field (keys %edge_attributes)
+ {
+ foreach my $attr (@{ $edge_attributes{$field} })
+ {
+ if ($graph->has_edge_attribute($from, $to, $attr))
+ {
+ print $FILE " $field=",
+ $graph->get_vertex_attribute($from, $to, $attr);
+ last;
+ }
+ }
+ }
+ print $FILE "\n";
+ ++$edge_num;
}
return 1;
@@ -120,10 +120,10 @@ Graph::Writer::HTK - write a perl Graph out as an HTK lattice file
=head1 SYNOPSIS
- use Graph::Writer::HTK;
-
- $writer = Graph::Reader::HTK->new();
- $reader->write_graph($graph, 'mylattice.lat');
+ use Graph::Writer::HTK;
+
+ $writer = Graph::Reader::HTK->new();
+ $reader->write_graph($graph, 'mylattice.lat');
=head1 DESCRIPTION
@@ -155,7 +155,7 @@ Neil Bowers E<lt>neil@bowers.comE<gt>
=head1 COPYRIGHT
-Copyright (c) 2000-2005, Neil Bowers. All rights reserved.
+Copyright (c) 2000-2012, Neil Bowers. All rights reserved.
Copyright (c) 2000, Canon Research Centre Europe. All rights reserved.
This module is free software; you can redistribute it and/or modify
74 lib/Graph/Writer/VCG.pm
View
@@ -1,16 +1,13 @@
#
# Graph::Writer::VCG - write a directed graph out in VCG format
#
-# $Id: VCG.pm,v 1.3 2005/01/02 19:04:05 neilb Exp $
-#
package Graph::Writer::VCG;
use strict;
+use warnings;
-use Graph::Writer;
-use vars qw(@ISA $VERSION);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
-@ISA = qw(Graph::Writer);
+use parent 'Graph::Writer';
+our $VERSION = '2.01';
#-----------------------------------------------------------------------
# Attribute type information
@@ -208,9 +205,9 @@ sub _write_graph
#-------------------------------------------------------------------
foreach $v (sort $graph->vertices)
{
- print $FILE " node: { title: \"$v\"";
- $aref = $graph->get_vertex_attributes($v);
- _render_attributes('node', $aref, $FILE, 1);
+ print $FILE " node: { title: \"$v\"";
+ $aref = $graph->get_vertex_attributes($v);
+ _render_attributes('node', $aref, $FILE, 1);
print $FILE " }\n";
}
print $FILE "\n";
@@ -220,10 +217,10 @@ sub _write_graph
#-------------------------------------------------------------------
foreach my $edge (sort _by_vertex $graph->edges)
{
- ($from, $to) = @$edge;
- print $FILE " edge: { sourcename: \"$from\" targetname: \"$to\"";
- $aref = $graph->get_edge_attributes($from, $to);
- _render_attributes('edge', $aref, $FILE, 1);
+ ($from, $to) = @$edge;
+ print $FILE " edge: { sourcename: \"$from\" targetname: \"$to\"";
+ $aref = $graph->get_edge_attributes($from, $to);
+ _render_attributes('edge', $aref, $FILE, 1);
print $FILE " }\n";
}
@@ -265,20 +262,21 @@ sub _render_attributes
@keys = grep(exists $attref->{$_}, keys %{$valid_attributes{$entity}});
if (@keys > 0)
{
- print $FILE "\n";
- foreach my $a (@keys)
- {
- $type = $valid_attributes{$entity}->{$a};
- if (ref $type || $type == VCG_ATTR_TYPE_INTEGER
- || $type == VCG_ATTR_TYPE_FLOAT)
- {
- print $FILE " ", ' ' x $depth, "$a: ", $attref->{$a}, "\n";
- }
- else
- {
- print $FILE " ", ' ' x $depth, "$a: \"", $attref->{$a}, "\"\n";
- }
- }
+ print $FILE "\n";
+ foreach my $a (@keys)
+ {
+ $type = $valid_attributes{$entity}->{$a};
+ if (ref $type || $type == VCG_ATTR_TYPE_INTEGER
+ || $type == VCG_ATTR_TYPE_FLOAT)
+ {
+ print $FILE " ", ' ' x $depth, "$a: ", $attref->{$a}, "\n";
+ }
+ else
+ {
+ print $FILE " ", ' ' x $depth,
+ "$a: \"", $attref->{$a}, "\"\n";
+ }
+ }
}
return int @keys;
}
@@ -293,14 +291,14 @@ Graph::Writer::VCG - write out directed graph in VCG format
=head1 SYNOPSIS
- use Graph;
- use Graph::Writer::VCG;
-
- $graph = Graph->new();
- # add edges and nodes to the graph
-
- $writer = Graph::Writer::VCG->new();
- $writer->write_graph($graph, 'mygraph.vcg');
+ use Graph;
+ use Graph::Writer::VCG;
+
+ $graph = Graph->new();
+ # add edges and nodes to the graph
+
+ $writer = Graph::Writer::VCG->new();
+ $writer->write_graph($graph, 'mygraph.vcg');
=head1 DESCRIPTION
@@ -320,7 +318,7 @@ as long as they are attributes understood by VCG.
Constructor - generate a new writer instance.
- $writer = Graph::Writer::VCG->new();
+ $writer = Graph::Writer::VCG->new();
This doesn't take any arguments.
@@ -328,7 +326,7 @@ This doesn't take any arguments.
Write a specific graph to a named file:
- $writer->write_graph($graph, $file);
+ $writer->write_graph($graph, $file);
The C<$file> argument can either be a filename,
or a filehandle for a previously opened file.
@@ -382,7 +380,7 @@ Neil Bowers E<lt>neil@bowers.comE<gt>
=head1 COPYRIGHT
-Copyright (c) 2001-2005, Neil Bowers. All rights reserved.
+Copyright (c) 2001-2012, Neil Bowers. All rights reserved.
Copyright (c) 2001, Canon Research Centre Europe. All rights reserved.
This script is free software; you can redistribute it and/or modify
11 lib/Graph/Writer/XML.pm
View
@@ -1,16 +1,15 @@
#
# Graph::Writer::XML - write a directed graph out as XML
#
-# $Id: XML.pm,v 1.3 2005/01/02 19:04:05 neilb Exp $
-#
package Graph::Writer::XML;
-use Graph::Writer;
+use strict;
+use warnings;
+
+use parent 'Graph::Writer';
use XML::Writer;
-use vars qw(@ISA $VERSION);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
-@ISA = qw(Graph::Writer);
+our $VERSION = '2.01';
#=======================================================================
145 lib/Graph/Writer/daVinci.pm
View
@@ -1,16 +1,13 @@
#
# Graph::Writer::daVinci - write a directed graph out in daVinci format
#
-# $Id: daVinci.pm,v 1.3 2005/01/02 19:04:05 neilb Exp $
-#
package Graph::Writer::daVinci;
use strict;
+use warnings;
-use Graph::Writer;
-use vars qw(@ISA $VERSION);
-$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/);
-@ISA = qw(Graph::Writer);
+use parent 'Graph::Writer';
+our $VERSION = '2.01';
#-----------------------------------------------------------------------
# List of valid daVinci attributes for the entire graph, per node,
@@ -56,15 +53,15 @@ sub _write_graph
@nodes = sort $graph->source_vertices;
if (@nodes == 0)
{
- die "expecting source vertices!\n";
+ die "expecting source vertices!\n";
}
print $FILE "[\n";
while (@nodes > 0)
{
- $node = shift @nodes;
- $self->_dump_node($graph, $FILE, $node, \%done, 1);
- print $FILE ",\n" if @nodes > 0;
+ $node = shift @nodes;
+ $self->_dump_node($graph, $FILE, $node, \%done, 1);
+ print $FILE ",\n" if @nodes > 0;
}
print $FILE "\n]\n";
@@ -77,15 +74,16 @@ sub _write_graph
@edges = sort _by_vertex $graph->edges;
for (my $i = 0; $i < @edges; $i++)
{
- ($from, $to) = @{ $edges[$i] };
- print $FILE " $from -> $to";
- $aref = $graph->get_graph_attributes($from, $to);
- @keys = grep(exists $aref->{$_}, @{$valid_attributes{'edge'}});
- if (@keys > 0)
- {
- print $FILE " [", join(',', map { "$_ = \"".$aref->{$_}."\"" } @keys), "]";
- }
- print $FILE ", " if $i < @edges - 1;
+ ($from, $to) = @{ $edges[$i] };
+ print $FILE " $from -> $to";
+ $aref = $graph->get_graph_attributes($from, $to);
+ @keys = grep(exists $aref->{$_}, @{$valid_attributes{'edge'}});
+ if (@keys > 0)
+ {
+ print $FILE " [", join(',',
+ map { "$_ = \"".$aref->{$_}."\"" } @keys), "]";
+ }
+ print $FILE ", " if $i < @edges - 1;
}
return 1;
@@ -119,53 +117,56 @@ sub _dump_node
if (exists $doneref->{$node})
{
- print $FILE ' ' x (2 * $depth), "r(\"Node $node\")";
+ print $FILE ' ' x (2 * $depth), "r(\"Node $node\")";
}
else
{
- print $FILE ' ' x (2 * $depth), "l(\"Node $node\", n(\"\"";
- $aref = $graph->get_vertex_attributes($node);
- @keys = grep(exists $aref->{$_}, @{$valid_attributes{'node'}});
- if (@keys > 0)
- {
- print $FILE ", [", join(', ', map { "a(\"$_\", \"".$aref->{$_}."\")" } @keys), "]";
- }
- else
- {
- print $FILE ", []";
- }
-
- $doneref->{$node} = 1;
-
- @children = $graph->successors($node);
- if (@children == 0)
- {
- print $FILE ", []";
- }
- else
- {
- print $FILE ",\n", ' ' x (2 * $depth + 1), "[\n";
- while (@children > 0)
- {
- $child = shift @children;
- print $FILE ' ' x (2 * $depth + 2), "l(\"Edge ${node}->$child\", e(\"\", [";
-
- # write out any attributes of the edge
- $aref = $graph->get_edge_attributes($node, $child);
- @keys = grep(exists $aref->{$_}, @{$valid_attributes{'edge'}});
- if (@keys > 0)
- {
- print $FILE join(', ', map { "a(\"$_\", \"".$aref->{$_}."\")" } @keys);
- }
-
- print $FILE "],\n";
- $self->_dump_node($graph, $FILE, $child, $doneref, $depth+2);
- print $FILE "))";
- print $FILE ",\n" if @children > 0;
- }
- print $FILE ' ' x (2 * $depth + 1), "]";
- }
- print $FILE "))";
+ print $FILE ' ' x (2 * $depth), "l(\"Node $node\", n(\"\"";
+ $aref = $graph->get_vertex_attributes($node);
+ @keys = grep(exists $aref->{$_}, @{$valid_attributes{'node'}});
+ if (@keys > 0)
+ {
+ print $FILE ", [", join(', ',
+ map { "a(\"$_\", \"".$aref->{$_}."\")" } @keys), "]";
+ }
+ else
+ {
+ print $FILE ", []";
+ }
+
+ $doneref->{$node} = 1;
+
+ @children = $graph->successors($node);
+ if (@children == 0)
+ {
+ print $FILE ", []";
+ }
+ else
+ {
+ print $FILE ",\n", ' ' x (2 * $depth + 1), "[\n";
+ while (@children > 0)
+ {
+ $child = shift @children;
+ print $FILE ' ' x (2 * $depth + 2),
+ "l(\"Edge ${node}->$child\", e(\"\", [";
+
+ # write out any attributes of the edge
+ $aref = $graph->get_edge_attributes($node, $child);
+ @keys = grep(exists $aref->{$_}, @{$valid_attributes{'edge'}});
+ if (@keys > 0)
+ {
+ print $FILE join(', ',
+ map { "a(\"$_\", \"".$aref->{$_}."\")" } @keys);
+ }
+
+ print $FILE "],\n";
+ $self->_dump_node($graph, $FILE, $child, $doneref, $depth+2);
+ print $FILE "))";
+ print $FILE ",\n" if @children > 0;
+ }
+ print $FILE ' ' x (2 * $depth + 1), "]";
+ }
+ print $FILE "))";
}
}
@@ -179,14 +180,14 @@ Graph::Writer::daVinci - write out directed graph in daVinci format
=head1 SYNOPSIS
- use Graph;
- use Graph::Writer::daVinci;
+ use Graph;
+ use Graph::Writer::daVinci;
- $graph = Graph->new();
- # add edges and nodes to the graph
+ $graph = Graph->new();
+ # add edges and nodes to the graph
- $writer = Graph::Writer::daVinci->new();
- $writer->write_graph($graph, 'mygraph.davinci');
+ $writer = Graph::Writer::daVinci->new();
+ $writer->write_graph($graph, 'mygraph.davinci');
=head1 DESCRIPTION
@@ -201,7 +202,7 @@ actually a set of classes developed by Jarkko Hietaniemi.
Constructor - generate a new writer instance.
- $writer = Graph::Writer::daVinci->new();
+ $writer = Graph::Writer::daVinci->new();
This doesn't take any arguments.
@@ -209,7 +210,7 @@ This doesn't take any arguments.
Write a specific graph to a named file:
- $writer->write_graph($graph, $file);
+ $writer->write_graph($graph, $file);
The C<$file> argument can either be a filename,
or a filehandle for a previously opened file.
@@ -244,7 +245,7 @@ Neil Bowers E<lt>neil@bowers.comE<gt>
=head1 COPYRIGHT
-Copyright (c) 2001-2005, Neil Bowers. All rights reserved.
+Copyright (c) 2001-2012, Neil Bowers. All rights reserved.
Copyright (c) 2001, Canon Research Centre Europe. All rights reserved.
This script is free software; you can redistribute it and/or modify
2  t/reader.t
View
@@ -55,7 +55,7 @@ $writer = Graph::Writer::HTK->new();
if (defined($reader) && defined($writer)
&& ($ingraph = $reader->read_graph($testfile))
&& $writer->write_graph($ingraph, $genfile)
- && compare($genfile, $testfile) == 0)
+ && compare($genfile, $testfile, -1) == 0)
{
print "ok 2\n";
} else {
10 t/simple.t
View
@@ -36,7 +36,7 @@ $expected = 't/data/simple.xml';
$writer = Graph::Writer::XML->new();
if (defined($writer)
&& $writer->write_graph($graph, $genfile)
- && compare($genfile, $expected) == 0)
+ && compare($genfile, $expected, -1) == 0)
{
print "ok 1\n";
} else {
@@ -52,7 +52,7 @@ $expected = 't/data/simple.htk';
$writer = Graph::Writer::HTK->new();
if (defined($writer)
&& $writer->write_graph($graph, $genfile)
- && compare($genfile, $expected) == 0)
+ && compare($genfile, $expected, -1) == 0)
{
print "ok 2\n";
} else {
@@ -68,7 +68,7 @@ $expected = 't/data/simple.dot';
$writer = Graph::Writer::Dot->new();
if (defined($writer)
&& $writer->write_graph($graph, $genfile)
- && compare($genfile, $expected) == 0)
+ && compare($genfile, $expected, -1) == 0)
{
print "ok 3\n";
} else {
@@ -84,7 +84,7 @@ $expected = 't/data/simple.vcg';
$writer = Graph::Writer::VCG->new();
if (defined($writer)
&& $writer->write_graph($graph, $genfile)
- && compare($genfile, $expected) == 0)
+ && compare($genfile, $expected, -1) == 0)
{
print "ok 4\n";
} else {
@@ -100,7 +100,7 @@ $expected = 't/data/simple.davinci';
$writer = Graph::Writer::daVinci->new();
if (defined($writer)
&& $writer->write_graph($graph, $genfile)
- && compare($genfile, $expected) == 0)
+ && compare($genfile, $expected, -1) == 0)
{
print "ok 5\n";
} else {

No commit comments for this range

Something went wrong with that request. Please try again.