Data::Hopen::G::GraphBuilder - fluent interface for building graphs
A GraphBuilder wraps a Data::Hopen::G::DAG and a current Data::Hopen::G::Node. It permits building chains of nodes in a fluent way. For example, in an App::hopen hopen file:
# $Build is a Data::Hopen::G::DAG created by App::hopen use language 'C'; my $builder = $Build->C::compile(file => 'foo.c'); # Now $builder holds $Build (the DAG) and a node created by # C::compile().
An optional name, in case you want to identify your Builder instances.
The current Data::Hopen::G::DAG instance, if any.
The current Data::Hopen::G::Node instance, if any.
Adds a node to the graph. Returns the node. Note that this does not change the builder's current node ("node").
Links the most recent node in the chain to the default goal in the DAG. If the DAG does not have a default goal, adds one called "all".
As a side effect, calling this function clears the builder's record of the current node and returns undef. The idea is that this function will be used at the end of a chain of calls. Clearing state in this way reduces the chance of unintentionally connecting nodes.
undef
Links the most recent node in the chain to the given goal in the DAG. Clears the builder's record of the current node and returns undef.
Connect one node to another, where both are wrapped in GraphBuilders. Usage:
GraphBuilder
$builder_1->to($builder_2); # No $builder_1->node has an edge to $builder_2->node
Returns undef, because chaining would be ambiguous. For example, in the snippet above, would the chain continue from $builder_1 or $builder_2?
$builder_1
$builder_2
Does not change the state of either GraphBuilder.
Given the name of a subroutine, wrap the given subroutine for use in a GraphBuilder chain such as that shown in the "SYNOPSIS". Usage:
sub worker { my $graphbuilder = shift; ... return $node; # Will automatically be linked into the chain } make_GraphBuilder 'worker'; # now worker can take a DAG or GraphBuilder, and the # return value will be the GraphBuilder.
The worker subroutine is called in scalar context.
worker
To install Data::Hopen, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Hopen
CPAN shell
perl -MCPAN -e shell install Data::Hopen
For more information on module installation, please visit the detailed CPAN module installation guide.