Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

graph::reader(3pm) [debian man page]

Graph::Reader(3pm)					User Contributed Perl Documentation					Graph::Reader(3pm)

NAME
Graph::Reader - base class for Graph file format readers SYNOPSIS
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 } DESCRIPTION
Graph::Reader is a base class for Graph file format readers. A particular subclass of Graph::Reader will handle a specific file format, and generate a Graph, represented using Jarkko Hietaniemi's Graph class. You should never create an instance of this class yourself, it is only meant for subclassing. If you try to create an instance of Graph::Reader, the constructor will throw an exception. METHODS
new() Constructor - generate a new reader instance. This 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(); It will throw an exception. read_graph() Read a graph from the specified file: $graph = $reader->read_graph($file); The $file argument can either be a filename, or a filehandle for a previously opened file. SUBCLASSING
To create your own graph format reader, create a module which subclasses Graph::Reader. For example, suppose DGF is a directed graph format - create a 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>) { } return 1; } 1; Note the leading underscore on the _read_graph() method. The base class provides the public method, and invokes the private method which you're expected to provide, as above. If you want to perform additional initialisation at construction time, you can provide an _init() method, 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; $self->SUPER::_init(); # 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'); SEE ALSO
Graph Jarkko Hietaniemi's modules for representing directed graphs, available from CPAN under modules/by-module/Graph/ Algorithms in Perl This O'Reilly book has a chapter on directed graphs, which is based around Jarkko's modules. Graph::Reader::XML A simple subclass of this class for reading a simple XML format for directed graphs. Graph::Writer A baseclass for Graph file format writers. AUTHOR
Neil Bowers <neil@bowers.com> COPYRIGHT
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 it under the same terms as Perl itself. perl v5.14.2 2012-02-14 Graph::Reader(3pm)

Check Out this Related Man Page

Graph::Reader::Dot(3pm) 				User Contributed Perl Documentation				   Graph::Reader::Dot(3pm)

NAME
Graph::Reader::Dot - class for reading a Graph instance from Dot format SYNOPSIS
use Graph::Reader::Dot; use Graph; $reader = Graph::Reader::Dot->new(); $graph = $reader->read_graph('mygraph.dot'); DESCRIPTION
Graph::Reader::Dot is a class for reading in a directed graph in the file format used by the dot tool (part of the AT+T graphviz package). Graph::Reader::Dot is a subclass of Graph::Reader, which defines the generic interface for Graph reader classes. METHODS AND CONFIGURATION
"new()" Constructor - generate a new reader instance. $reader = Graph::Reader::Dot->new(); This doesn't take any arguments. "read_graph()" Read a graph from a file: $graph = $reader->read_graph( $file ); The $file argument can be either a filename or a filehandle of a previously opened file. $Graph::Reader::Dot::UseNodeAttr Controls, if implicit node attributes given by the dot directive "node[]" will be merged into (new) nodes. Setting it to 0 or "undef" (default) will not disable this feature. Setting it to any other value will enable this feature. $Graph::Reader::Dot::UseEdgeAttr Controls, if implicit edge attributes given by the dot directive "edge[]" will be merged into edges. Setting it to 0 or "undef" (default) will not disable this feature. Setting it to any other value will enable this feature. RESTRICTIONS
o Default (graph) attributes in subgraphs (i.e. inside "{}") are not processed. o Sub nodes as used by dot's "record" node shape are supported. o Undirected graphs will be treated as directed graphs. This means that the "--" edge operator works as the "->" edge operator. o Be aware that you are loosing scope information on writing back the graph. o Multiple "node[]" or "edge[]" statements in the same scope are not correctly supported. SEE ALSO
http://www.graphviz.org/ The home page for the AT+T graphviz toolkit that includes the dot tool. Graph::Reader The base class for Graph::Reader::Dot. Graph::Writer::Dot Used to serialise a Graph instance in Dot format. Graph Jarkko Hietaniemi's classes for representing directed graphs. Parse::Yapp Another base class for Graph::Reader::Dot. The Parse::Yapp module comes with the following copyright notice: The Parse::Yapp module and its related modules and shell scripts are copyright (c) 1998-1999 Francois Desarmenien, France. All rights reserved. You may use and distribute them under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. If you use the "standalone parser" option so people don't need to install Parse::Yapp on their systems in order to run you software, this copyright noticed should be included in your software copyright too, and the copyright notice in the embedded driver should be left untouched. AUTHOR
Mark A. Hillebrand <mah@wjpserver.cs.uni-sb.de> COPYRIGHT
Copyright (c) 2001 by Mark A. Hillebrand. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-02-12 Graph::Reader::Dot(3pm)
Man Page