CallGraph::Node - represent a subroutine as a node in a call graph


NAME

CallGraph::Node - represent a subroutine as a node in a call graph


SYNOPSIS

    my $sub1 = CallGraph::Node->new(name => 'main', type => 'internal');
    my $sub2 = CallGraph::Node->new(name => 'mysub', type => 'external');
    $sub1->add_call($sub2);
    print $sub1->dump;
    my @calls = $sub1->calls;
    my @callers = $sub2->callers;
    print $sub1->name; # prints 'main'
    print $sub1->type; # prints 'internal'


DESCRIPTION

This module creates a node within a ``call graph'' for a program. A node corresponds to a subroutine (or function, method, or whatever it's called), and it has the properties 'name' and 'type'. Subroutines are linked to one another by 'calls'.


METHODS

my $sub = CallGraph::Node->new(option => value, ...)
Creates a new node. The available options are 'name' and 'type'. These properties really don't mean anything as far as CallGraph::Node is concerned. However, CallGraph expects the name to be unique within a graph, and uses the values 'internal' or 'external'.

$sub->add_call($sub2)
Add a link implying that $sub calls $sub2.

my @calls = $sub->calls
Return a list of calls made by $sub. The items in the list are CallGraph::Node items themselves.

my @callers = $sub->callers
Return a list of calls received by $sub. The items in the list are CallGraph::Node items themselves.

my $name = $sub->name;
$sub->name($new_name);
Get or set the name of the subroutine.

my $type = $sub->type;
$sub->type($new_type);
Get or set the type of the subroutine.

my $dump = $sub->dump(option => value, ...)
Dump the call graph, starting from $sub, into a string representation. The options are passed to the CallGraph::Dumper manpage.


VERSION

0.55


SEE ALSO

the CallGraph manpage, the CallGraph::Dumper manpage, the CallGraph::Lang::Fortran manpage


AUTHOR

Ivan Tubert <itub@cpan.org>


COPYRIGHT

Copyright (c) 2004 Ivan Tubert. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 CallGraph::Node - represent a subroutine as a node in a call graph