Debian Codegraph @

examples/as_graphviz

raw
1 #!/usr/bin/perl -w
2
3 #############################################################################
4 # This example is a bit outdated, please use the new bin/graph-easy script -
5 # which is after "make install" available on any command line in your system.
6
7 # Convert an input file containing a Graph::Easy description to
8 # graphviz output that can be feed to dot etc.
9
10 # Example usage:
11 # examples/as_graphviz t/in/2nodes.txt | dot -Tpng >test.png
12 # echo "[ A ] -> [ B ]" | examples/as_graphviz | dot -Tpng >test.png
13
14 BEGIN { $|++; }
15
16 use strict;
17 use lib 'lib';
18 use Graph::Easy::Parser;
19
20 my $file = shift;
21
22 my $parser = Graph::Easy::Parser->new( debug => 0 );
23
24 if (!defined $file)
25 {
26 $file = \*STDIN;
27 binmode STDIN, ':utf8' or die ("binmode STDIN, ':utf8' failed: $!");
28 }
29 binmode STDERR, ':utf8' or die ("binmode STDERR, ':utf8' failed: $!");
30 my $graph = $parser->from_file( $file );
31
32 die ($parser->error()) unless defined $graph;
33 binmode STDOUT, ':utf8' or die ("binmode STDOUT, ':utf8' failed: $!");
34 print $graph->as_graphviz();
35