Thank you Mark and Ken. Your suggestions have been very helpful. There are certainly many options for me to pursue now. I will do some careful profiling and see which approach is most suitable. -Patrick
On Mar 16, 8:14 pm, Mark Engelberg <mark.engelb...@gmail.com> wrote: > On Wed, Mar 16, 2011 at 4:35 PM, CuppoJava <patrickli_2...@hotmail.com>wrote: > > > The problem arises after the program as been running for a long time > > and the value of the counter is very high. There might be only two > > Nodes in use, but one Node might have an id = 1 (because it was one of > > the first ones created), and the other Node could have an id = 1000000 > > (because it was only recently created). Now the cost of allocating the > > vector is too great. > > For many graph applications, node deletion is an uncommon operation. If you > have heavy node deletion, it's certainly possible that your node numbers > have a lot of gaps. If you think of the id numbering as being analogous to > assigning marker addresses in a dedicated region of memory, then it's > basically a defrag issue. The freelist method is one option, but it's not > the only one. You could track how many nodes are in the graph and you track > the next available id. When the number of nodes falls below a certain > fraction of the max id in the graph, you could "defrag" and go through and > renumber all the nodes. > > It's hard to figure out the "best" way without knowing the exact > application, but hopefully this gives you some ideas to play with. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en