#!/usr/bin/perl -w ############################################################################# # This example is a bit outdated, please use the new bin/grapheasy script - # which is after "make install" available in your system as simple as # "grapheasy" on any command line prompt. ############################################################################# # This script uses examples/common.pl to generate some example graphs and # prints them as HTML page. Use it like: # ewxamples/html.pl >test.html # and then open test.html in your favourite browser. use strict; use warnings; BEGIN { chdir 'examples' if -d 'examples'; } require "common.pl"; my $graph = Graph::Easy->new(); my @toc = (); my $html = $graph->html_page_header(); $html .= < h1 { border-bottom: 1px solid black; padding-bottom: 0.2em; } h2 { border-bottom: 1px solid grey; padding-bottom: 0.2em; margin-bottom: 0em; } div { margin-left: 2em; } .graph { margin-left: 2em; }

Graph-Simple Test page

This page was automatically created at ##time## by examples/html.pl running Graph::Easy v##version##.

On each of the following testcases you will see a text representation of the graph on the left side, and on the right side the automatically generated HTML+CSS code.

Notes:

Testcases:

##TOC## HTML ; # generate the parts and push their names into @toc gen_graphs($graph, 'html'); $html .= $graph->html_page_footer(); my $toc = '\n"; # insert the TOC $html =~ s/##TOC##/ $toc /; $html =~ s/##time##/ scalar localtime() /e; $html =~ s/##version##/$Graph::Easy::VERSION/e; print $html; # all done; 1; ############################################################################# sub out { my ($graph,$method) = @_; $method = 'as_' . $method; my $t = $graph->nodes() . ' Nodes, ' . $graph->edges . ' Edges'; my $n = $t; $n =~ s/\s/_/; $html .= "

$t

\n" . "
\n" . "

As Text

\n" . "
" . $graph->as_txt() . "
" . "
\n" . "

As HTML:

\n" . $graph->$method() . "
\n" . "
 
\n\n"; push @toc, $t; }