The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Graph::Reader::Graph6 - read Graph.pm from graph6 or sparse6 format

SYNOPSIS

 use Graph::Reader::Graph6;
 my $reader = Graph::Reader::Graph6->new;
 $graph = $reader->read_graph('filename.txt');
 $graph = $reader->read_graph($filehandle);

DESCRIPTION

Graph::Reader::Graph6 reads a graph6 or sparse6 format file and returns a new Graph.pm object. These file formats are per

Sparse6 can have multi-edges and self loops and they are added to the resulting graph in its usual way.

The format only contains vertex numbers 0 to n-1. They are made into vertex names as strings like "000" to "999" with however many decimal digits are needed for the number of vertices. This is designed to be round-trip clean to an alphabetical re-write by Graph::Writer::Graph6 or Graph::Writer::Sparse6.

See Graph::Graph6 for further notes on the formats.

FUNCTIONS

$parser = Graph::Reader::Graph6->new()

Create and return a new parser object.

$graph = $parser->read_graph($filename_or_fh)

Read a graph from $filename_or_fh. The return is a new Graph object if successful, or false for empty file or at end of file.

A file can contain multiple graphs, one per line (each either graph6 or sparse6). A filehandle is left positioned at the start of the next line, ready to read the next graph (or EOF).

Any invalid data or file read error is a croak(). Is that the intention for Graph::Reader classes? Perhaps this will change.

SEE ALSO

Graph, Graph::Reader

Graph::Writer::Graph6, Graph::Writer::Sparse6, nauty-showg(1)

HOME PAGE

http://user42.tuxfamily.org/graph-graph6/index.html

LICENSE

Copyright 2015 Kevin Ryde

Graph-Graph6 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Graph-Graph6 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Graph-Graph6. If not, see http://www.gnu.org/licenses/.