views:

401

answers:

2

It appears that a certain project of mine will require the use of quad-trees, something that I have never worked with before. From what I have read they should allow substantial performance enhancements than a brute-force attempt at the problem would yield. Are any of these python modules any good?

EDIT 1: Does anyone know of a better implementation than the one presented in the pygame wiki?

EDIT 2: Here are a few resources that others may find useful for path-finding techniques in Python.

A: 

Sometimes it is not obvious how to implement data structures like trees in Python.

For instance,

     d
  b     f
 a c   e g

is a simple binary tree structure. In Python you would represent it like so:

[d,b,f] is a node with a left and right subtree. To represent the full tree you would have:

[d,[b,a,c],[f,e,g]] 

Beyond that, of course you need to implement the various algorithms to manipulate your trees because a quadtree is more than just some data, it is a set of rules about how to insert and delete nodes. If this is not a coursework question, then http://pypi.python.org/pypi/Quadtree/0.1.2 would probably be a good idea.

Michael Dillon
Quadtree 0.1.2 will not work in Python 3.1 since there is no setuptools. The source needs to be compiled first to work on Windows.
Noctis Skytower
If you really need the performance, then you could compile the module for Python 3.1. If you can't do this yourself, then go onto comp.lang.python and ask if there is someone who can do it for you.
Michael Dillon
+1  A: 

The python package index produces 2 other libraries when searching for quadtree : http://pypi.python.org/pypi?%3Aaction=search&term=quadtree&submit=search

disclaimer : never used quadtrees or any of these libraries.

gurney alex
This appears to be the best answer. It does not help, but it is the best.
Noctis Skytower