There are several algorithms for tree structures, each with its own benefits. An app called django-treebeard, an alternative to django-mptt, which is used by Django CMS, provides support for three tree forms:
- Adjacency List trees are simple structures, where each node has a parent attribute. Although read operations are fast, this comes at the cost of slow writes.
- Nested Sets trees and MPTT trees are the same; they structure nodes as sets nested beneath the parent. This structure also provides very fast read access, at the cost of more expensive writing and deletion, particularly when writes require some particular ordering.
- Materialized Path trees are built with each node in the tree having an associated path attribute, which is a string indicating the full path from the root to the node—much like a URL path indicates...