As a necrohipposadist (beater of dead horses), I'll add...

"Sterin, Ilya" <[EMAIL PROTECTED]> writes:

> Well guess not, since something like this...
> 
> {
>   my ($a, $b, $c);
> 
>   $a = \$b;
>   $b = \$c;
>   $c = \$a;
> }
> 
> would definitelly be hard, resource consuming to implement a circular
> reference count.

Even that's not that difficult.  There's just one loop.  How about:

sub newgraph {
  my $noderef = shift;
  my @nodes = @$noderef;
  my $edgesref = shift;
  my @edges = @$edgesref;

  my %graph;

  foreach (@nodes) { $graph{$_} = [] }
  while (@edges) {
    my $source = shift @edges;
    my $dest   = shift @edges;
    push @$graph{$source},$graph{$dest};
  }
}

In this horrid little data structure, every reference of interest is a
reference to arrays of references, all of which are parts of circular
references.  This is not necessarily a good way to store a directed
graph, but it works (and some would think it has some benefits in some
cases).  But each push could introduce lots and lots of new loops that
would have to be accounted for.

However, more realistically, I could imagine someone coding a tree
where each node had pointers to its parent, its children, its
siblings, its "next" and "previous" nodes, etc.  All of which would
lead to numerous circuits.  Again, each addition to the tree would
introduce numerous, potentially hundreds or thousands, of circuits.
The same would happen on every delete, too.



> 
> Ilya
> 

Reply via email to