Last active
August 29, 2015 14:11
-
-
Save ywatase/e510f8c8c725a55c2096 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use utf8; | |
use Plack::Request; | |
use Graph::Easy; | |
# cpanm Graph::Easy::As_svg; | |
my $body = <<END; | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<h1>Graph::Easy sample</h1> | |
%s | |
</body> | |
</html> | |
END | |
sub svg { | |
my $graph = Graph::Easy->new; | |
$graph->add_edge('A','B'); | |
$graph->add_edge('B','C'); | |
$graph->add_edge('C','D'); | |
$graph->add_edge('B','E'); | |
$graph->add_edge('E','F'); | |
$graph->add_edge('F','G'); | |
$graph->add_edge('D','G'); | |
$graph->as_svg; # Graph::Easy::As_svg | |
} | |
my $app = sub { | |
my $env = shift; | |
my $req = Plack::Request->new($env); | |
my $res = $req->new_response(200); | |
$res->body(sprintf $body, svg() ); | |
$res->finalize; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment