Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 2012-01-28 06:11:55 -0600

DSM gravatar image

Yeah, that's a side effect of the way the classes work. I'm not sure what the best way to handle this is:

(1) Give up on clever naming entirely.

(2) Check whether the name still makes sense whenever the graph is changed and update accordingly. This would be very silly and very expensive.

(3) Check whether the name still makes sense whenever the name is printed, and update accordingly. This makes a lot more sense but could still be pretty expensive, although it could have a modification-invalidating cache.

(4) Whenever a graph has nodes or vertices changed, in-place or otherwise, set a "modified" flag. If the modified flag is set, print the generic string instead, without testing whether the name would still apply. This would add one extra operation to every graph change, but it should be pretty fast.

ISTR this came up on one of the mailing lists within the last six months or so.