[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Graph library 0.1
From: |
Alex Lancaster |
Subject: |
Graph library 0.1 |
Date: |
Wed, 13 Aug 1997 02:19:31 +1000 |
This is a question mainly directed at Manor, I think?
I am using his excellent graph library (0.1), however I am having trouble
dropping objects from the canvas, in an interactive fashion (i.e. via a
probe or a modelSwarm window).
What I am doing is subclassing the DiGraphNode class, and then calling the
inherited (but not over-ridden) "-drop" function, and I get a segmentation
fault. This happens when the -drop function attempts to remove the links
from the list, i.e.:
-(void) drop {
// ...
[fromList forEach: M(drop)}
// ...
}
this seems to generate a segmentation fault.
I got around this by writing a new function:
-dropAllLinks {
id index, link;
index = [fromList begin: globalZone];
[index setLoc: Start];
while ( ( link = [index next] ) ) {
[index remove];
[forList remove: link]
[link drop]
}
[index drop];
// same for toList...
return self;
}
this seemed to work OK in this case, it seemed that just sending a drop
message (as in the first example) confused the index somehow, because in
dropping the link you are actually modifying the underlying collection (I
think this is right??). However I am still having trouble working out how
do this in general, without writing some very ugly and convoluted code.
Basically in my app, I am creating Nodes and Links, and I want the Canvas
to remain visible to the user, but I want a way to be able to either drop
link(s), or drop links and nodes together (i.e. an entire instance of a
DiGraph), interactively. I am finding that I am needing to write my own
functions to do all of this. I have successfully written code to remove all
the links in a network, but not successfully managed to remove an entire
DiGraph (i.e. all nodes and links), nor even a single DiGraphNode instance,
from the Canvas without causing a segmentation fault at some point (even
when I re-implement the drop functions for all relevant classes). So I am
wondering whether there is a bug in the library in this area, or whether I
am doing something drastically wrong (a more likely case!!)
I am hoping that Manor (or someone out there) has grappled with the same
issues and has maybe a sample of good programming style to follow when
using this library in this way.
I can send code fragments if necessary.
Regards,
Alex
////////////////////////////////////////////////////////////
Alex Lancaster
e-mail: <address@hidden> tel: +61-2-9565-5774 (H)
web: http://www.real.net.au/~alex
////////////////////////////////////////////////////////////
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
==================================