2

I want to use vocabulary trees (which is not necessarily binary) in my program and I already have a general idea on how to create a tree class but I was wondering if there are any c++ libraries that are useful for that purpose. If not I would like to know about the methods I can use to manage my tree faster( add/remove/access nodes), like storing them in consecutive memory locations.

thank you

soroosh.strife
  • 1,181
  • 4
  • 19
  • 45

2 Answers2

2

You can use The Boost Graph Library to model all kinds of trees.

piokuc
  • 25,594
  • 11
  • 72
  • 102
2

Though std::map and std::set get mentioned in oleskii's link they are binary trees. Any n-ary tree can be rearranged to a binary tree, but that may not help you, since the re-organisation will take time. The boost graph libraries are more general purpose.

A quick google for n-ary trees C++" just turned up treetree

"Treetree is a header-only C++ library that implements a generic tree-structured container class according to STL conventions"

If you want to make you current tree implementation faster, you should measure where it is currently slow.
Check simple things, e.g. make sure you pass by reference rather than by copy.

Community
  • 1
  • 1
doctorlove
  • 18,872
  • 2
  • 46
  • 62