Tree::Family - Represent and visualize a family tree.
use Tree::Family; my $tree = Tree::Family->new(filename => '/tmp/mytree.dmp'); my $person = Tree::Family::Person->new(name => 'Fred'); my $nother = Tree::Family::Person->new(name => 'Wilma'); $person->spouse($nother); $tree->add_person($person); $tree->add_person($nother); for ($tree->people) { print $_->name; } my $dot_file = $tree->as_dot;
Use this module to represent spousal and parental relationships among a group of people, and generate a graphviz "dot" file to visualize them.
my $tree = Tree::Family->new(filename => '/tmp/foobarfamily.dmp');
Write the family tree to a file
$tree->write
Add a person to the tree
$tree->add_person($joe);
$joe should be a Tree::Family::Person object.
Delete a person
$tree->delete_person($joe)
Get a list of all the people in the tree
Find a person, specifying keys and values to search for.
$tree->find(id => 'sam');
$tree->find(first_name => 'joe', last_name => 'dimaggio');
The numeric smallest generation.
The numeric highest generation.
Write out a .dot file (graphviz format).
$tree->write("output.dot");
Return the text for a .dot graphviz file
print $tree->as_dot
Tree::Family::Person family.cgi (in this distribution)
Brian Duggan, <bduggan at matatu.org>
<bduggan at matatu.org>
graphviz uses a lot of heuristics to create a nice layout. This package attempts to micro-manage the contents of the dot file in order to produce a nice layout, while still letting graphviz do the brunt of the work. This approach doesn't always produce optimal results. Patches welcome.
Copyright 2006 Brian Duggan, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tree::Family, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree::Family
CPAN shell
perl -MCPAN -e shell install Tree::Family
For more information on module installation, please visit the detailed CPAN module installation guide.