Well you're right about DESTROY; after rereading
perlobj
I see it doesn't actually cause any reference destruction, but just gives the programmer a last chance to do some custom cleanup. So that's out. As for Graph::Directed, it utilizes an
adjacency matrix which is why it doesn't introduce the reference problems I'm encountering. I chose to write my own graph class utilizing an adjacency list though since the graph itself must be persisted in a database, and building a table with an 'origin' => 'destination' mapping seemed more natural than trying to store a matrix or translate between the two implementations when moving between disk and memory.
Your last suggestion may well work, although I'll have to make some changes to the way I treat my graph object references. Actually perlobj suggests basically the same thing: "the best solution is to create a non-recursive container class that holds a pointer to the self-referential data structure. Define a DESTROY method for the containing object's class that manually breaks the circularities in the self-referential structure."
thanks for the input davido.
"The dead do not recognize context" -- Kai, Lexx
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.