Jack Maney

NAME

Hypatia::GraphViz2 - Hypatia Bindings for GraphViz2

VERSION

version 0.015

SYNOPSIS

        use strict;
        use warnings;
        use Hypatia;
        
        my $hypatia=Hypatia->new({
                back_end=>"GraphViz2",
                dbi=>{
                        dsn=>"dbi:Pg:dbname=some_db;host=localhost",
                        username=>"bob",
                        password=>"dole",
                        query=>"select a.user_id as user_1,b.user_id as user_2
                        from users a
                        join users b on (a.id = b.frend_id)
                        where a.user_id != b.user_id"
                }
                ,columns=>{v1=>"user_1",v2=>"user2"}
                ,directed=>1
        });
        
        # $gv2 is now a GraphViz2 object, with all of the default label, color, shape, etc settings,
        # except for the fact that the graph is directed
        my $gv2 = $hypatia->graph;
        
        $gv2->run(format=>"png",output_file=>"user_social_graph.png");

DESCRIPTION

As with the other Hypatia plugins, this module extends Hypatia::Base. The API is mostly the same as that for Hypatia::Chart::Clicker, with the biggest exception being that only two column types are allowed: v1 and v2 (see below).

For the other attributes and methods, look at Hypatia::Base.

ATTRIBUTES

columns

For now, the only acceptable column types are v1 and v2. If this attribute is not provided, then column guessing works as follows: if there are two columns, then the first is assigned to v1 and the second to v2, otherwise an error is thrown.

directed

This boolean value determines whether or not the GraphViz2 object emitted from the graph method (see below) will represent a directed graph. The default value is 0.

METHODS

graph([$data]) aka chart([$data])

Returns the GraphViz2 object represented by the data, with edges represented by (non-null) (v1,v2) pairs.

TODO

1. Write more robust unit tests, as soon as I can find out how to list the nodes and edges from a GraphViz2 object.
2. Look through the list of GraphViz attributes and figure out which would be the most useful to include as column types (definitely vertex shapes and colors, as well as edge colors and labels, but what else?).
3. Include the attributes from part 2. as column types and apply the attributes (if provided) within the graph method.

AUTHOR

Jack Maney <jack@jackmaney.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Jack Maney.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.