Graph::Reader::TGF - Perl class for reading a graph from TGF format.
use Graph::Reader::TGF; my $obj = Graph::Reader::TGF->new; my $graph = $obj->read_graph($tgf_file);
new()
Constructor. This doesn't take any arguments. Returns Graph::Reader::TGF object.
read_graph($tgf_file)
Read a graph from the specified file. The argument can either be a filename, or a filehandle for a previously opened file. Returns Graph object.
TGF = Trivial Graph Format TGF file format is described on L<English Wikipedia - Trivial Graph Format|https://en.wikipedia.org/wiki/Trivial_Graph_Format> Example: 1 First node 2 Second node # 1 2 Edge between the two
new(): Parameter 'edge_callback' isn't reference to code. Parameter 'vertex_callback' isn't reference to code.
# Pragmas. use strict; use warnings; # Modules. use Graph::Reader::TGF; use IO::Barf qw(barf); use File::Temp qw(tempfile); # Example data. my $data = <<'END'; 1 First node 2 Second node # 1 2 Edge between the two END # Temporary file. my (undef, $tempfile) = tempfile(); # Save data to temp file. barf($tempfile, $data); # Reader object. my $obj = Graph::Reader::TGF->new; # Get graph from file. my $g = $obj->read_graph($tempfile); # Print to output. print $g."\n"; # Clean temporary file. unlink $tempfile; # Output: # 1-2
# Pragmas. use strict; use warnings; # Modules. use Graph::Reader::TGF; use IO::Barf qw(barf); use File::Temp qw(tempfile); # Example data. my $data = <<'END'; 1 Node #1 2 Node #2 3 Node #3 4 Node #4 5 Node #5 6 Node #6 7 Node #7 8 Node #8 9 Node #9 10 Node #10 # 1 2 1 3 1 5 1 6 1 10 3 4 6 7 6 8 6 9 END # Temporary file. my (undef, $tempfile) = tempfile(); # Save data to temp file. barf($tempfile, $data); # Reader object. my $obj = Graph::Reader::TGF->new; # Get graph from file. my $g = $obj->read_graph($tempfile); # Print to output. print $g."\n"; # Clean temporary file. unlink $tempfile; # Output: # 1-10,1-2,1-3,1-5,1-6,3-4,6-7,6-8,6-9
Encode, Error::Pure, Graph::Reader.
base class for Graph file format readers
Install the Graph::Reader modules.
https://github.com/tupinek/Graph-Reader-TGF
Michal Špaček mailto:skim@cpan.org
http://skim.cz
© Michal Špaček 2014-2015 BSD 2-Clause License
0.03
To install Graph::Reader::TGF, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graph::Reader::TGF
CPAN shell
perl -MCPAN -e shell install Graph::Reader::TGF
For more information on module installation, please visit the detailed CPAN module installation guide.