NAME Persistent::Graph

Class encapsulating a persistent graph.

Copyright &copy 1997 Curtis E. Dyreson. All rights reserved. Please be aware of the the Licence manpage and the Version manpage.


DESCRIPTION

A persistent graph is a DBMDatabase::Table mapping from nodes to to nodes.


METHODS


new($db, $name)

Create a new persistent graph.


IdIdListImage()

Return an Id to IdList image of the graph.


IdKeysImage()

Return an Id to IdList image of the graph.


addEdge($from, $to)

Add an edge.


toNodeSet($from) =over 4 =item * $from - An <A HREF="http://www.eecs.wsu.edu/~cdyreson/pub/JumpingSpider/docs/DBMDatabase/Id.html">DBMDatabase::Id</A>, the node to start from =back Get the set of nodes that are the 'to' set for this edge. Returns an <A HREF="http://www.eecs.wsu.edu/~cdyreson/pub/JumpingSpider/docs/DBMDatabase/IdSet.html">DBMDatabase::IdSet</A>, the set of nodes. =cut #--------------------------------------------------------------------- sub toNodeSet { my ($self, $from) = @_; my ($edges) = $self->{'edges'}; my ($t) = $edges->retrieveTuple($from); if ($t) { return $t->getValueAsIdSet(); } else { return new IdSet(); } } #---------------------------------------------------------------------


reachableSetWithCaching(from, cache)

Get the set of nodes that are reachable from this node. Allow cycles, and cache intermediate results to build a complete table of reachable nodes. Returns an DBMDatabase::IdSet, the set of reachable nodes.


reachableSet($from) =over 4 =item * $from - An <A HREF="http://www.eecs.wsu.edu/~cdyreson/pub/JumpingSpider/docs/DBMDatabase/Id.html">DBMDatabase::Id</A>, the node to start from =back Get the set of nodes that are reachable from this node. And allow cycles! Returns an <A HREF="http://www.eecs.wsu.edu/~cdyreson/pub/JumpingSpider/docs/DBMDatabase/IdSet.html">DBMDatabase::IdSet</A>, the set of reachable nodes. =cut #--------------------------------------------------------------------- sub reachableSet { my ($self, $from) = @_; #// the result set my ($result) = new IdSet(); #// put the current node into the result $result->insert($from); #// get the nodes reachable from this node my ($edges) = $self->{'edges'}; my ($t) = $edges->retrieveTuple($from); if ($t) { #// for each reachable node my $toSet = $t->getValueAsIdSet(); my ($id); foreach $id ($toSet->enumerate()) { #// is it a member already of the result? if (!$result->memberOf($id)) { #// follow the node $self->_reachableSetInner($result,$id); } } } return $result; } #---------------------------------------------------------------------


reachableSetStopAtMeasure($from, $stopMeasure, $unitToMeasureTable)

Get the set of nodes at the indicated measure that are reachable from this initial node. Assume for now that the graph is a strict hierarchy, in future we will relax this assumption.


enumerate()

Return a reference to the dbm file.


save()

Save any changes to the persistent graph to disk.


PRIVATE METHODS


_reachableSetInner($result, $from)

Get the set of nodes that are reachable from this node. And allow cycles! Build the resulting set in the $result variable. A helper function for reachableSet.