Graph::Reader::Graph6 - read from graph6, sparse6 or digraph6 file


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

 # or use once,
 $graph = Graph::Reader::Graph6->new->read_graph('filename.txt');


Graph::Reader::Graph6 is a subclass of Graph::Reader.



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

The formats only contain 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.

graph6 and sparse6 are undirected and digraph6 is directed. The graph is created undirected or directed accordingly. sparse6 and digraph6 can have self loops and they are added to the graph in its usual way. sparse6 can have multi-edges. If any are found then the graph is created countedged.

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


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

Create and return a new reader object.

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

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

A file can contain multiple graphs, one per line and each any of graph6, sparse6 or digraph6. 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(). Not sure if that the intention for Graph::Reader classes. Perhaps this will change.


For sparse6 multi-edges, an application might prefer multiedged rather than countedged for later manipulations. Perhaps some constructor options could be taken to select that or other possibilities (such as say multi-edge on graph6 or digraph6 too ready for later manipulations).


Graph, Graph::Reader, Graph::Graph6

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



Copyright 2015, 2016, 2017, 2018 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