tree

How to convert Directed Acyclic Graph (DAG) to Tree

Hi there, I have been looking for C# examples to transform a DAG into a Tree. Does anyone have an examples or pointers in the right direction? Clarification Update I have a graph that contains a list of modules that my application is required to load. Each module has a list of modules it depends on. For example here are my modules, ...

build tree from flat list in XML using xslt

hi all, i use a minimalist MVC framework, where the PHP controler hands the DOM model to the XSLT view (c.f. okapi). in order to build a navigation tree, i used nested sets in MYSQL. this way, i end up with a model XML that looks as follows: <tree> <node> <name>root</name> <depth>0</depth> </node> <node> ...

Different trees

What are "Splay trees”, “Red-black trees”, AVL Tree, B-Tree and T-tree? looking for good implementations. Thanks ...

How can I generate a tree structure from a table in a database?

I'm trying to generate a tree structure from a table in a database. The table is stored flat, with each record either having a parent_id or 0. The ultimate goal is to have a select box generated, and an array of nodes. The code I have so far is : function init($table, $parent_id = 0) { $sql = "SELECT id, {$this->parent_id_field},...

Displaying CSS images in div updated by Ajax

I wonder if anyone can help. An HTML div in a page of mine contains a tree control which is shown or hidden depending upon a button pressed by a user. The button triggers an Ajax event which sets a variable on the server to show or hide the tree so that the state is persisted. But here's the problem; when the tree is re-displayed, the i...

Tree Abstact Data Type

I'm doing a unit called Data Structures and Algorithms. We've just started and my professor has just taught us the basics of what Algebraic Semantics is and what Axioms are etc. Till now, I've just used Trees in the form of arrays. Not using the signature for pre-ordered tree as tree(value, tree, tree) where value is the value in the nod...

XSLT: Walking a tree-like structure

I have an xml document, that has a list of categories: <categories> <category id="1" parent="0">Configurations</category> <category id="11" parent="13">LCD Monitor</category> <category id="12" parent="13">CRT Monitor</category> <category id="13" parent="1"">Monitors</category> <category id="123" parent="122">Printer<...

Flex Tree Dynamic data and Python, use case questions

Hi, On the flex side i have a tree component which gets his Tree data from the backend. On the backend side we have Django using Pyamf for communication with Flex. We use MPTT (Modified Preorder Tree Traversal) Dango app to store Categories in a tree like fashion (a category Class has a parent field). We also have an Item Model Class w...

(More) Efficient locking when rotating nodes in threaded binary tree

So, I've come up with this scheme for locking nodes when rotating in a binary tree that several threads have both read and write access to at the same time, which involves locking four nodes per rotation, which seems to be an awfully lot? I figured some one way smarter then me had come up with a way to reduce the locking needed, but goog...

Nested Set Model: Is there a simple way to query the children of a node?

I've been using the crap out of the Nested Set Model lately. I have enjoyed designing queries for just about every useful operation and view. One thing I'm stuck on is how to select the immediate children (and only the children!) of a node. To be honest, I do know of a way - but it involves unmanageable amounts of SQL. I'm sure there is...

What is the best data structure to use for an offspring relationship?

There must be a standard data structure to hold, for instance, dog breeding information, plant genetic crossbreeding, and complex human relationships. One might think it would be an easy tree structure, but the combination of two (or more, for genetic engineering) parents per offspring, multiple different offspring per parent set, multi...

I'd like to use the "nested set model" but I'm obliged to have a GUID as primary key. How can I do without integers as pk?

I'm not aware how deep my tree will be. So I think the NSM is fit for me, reading some docs. In sql, this model suppose I'm using an integer value as primary key. I thought to create a twin table only to store the ints (PK,left,righ) connected by a relation one-to-one with the real table. Things are complicating and it is a waste of spac...

Hierarchy traversal and comparison modules for Python?

I deal with a lot of hierarchies in my day to day development. File systems, nested DAG nodes in Autodesk Maya, etc. I'm wondering, are there any good modules for Python specifically designed to traverse and compare hierarchies of objects? Of particular interest would be ways to do 'fuzzy' comparisons between two nearly identical hier...

Best data structure in C for these two situations?

I kinda need to decide on this to see if I can achieve it in a couple of hours before the deadline for my school project is due but I don't understand much about data structures and I need suggestions... There's 2 things I need to do, they will probably use different data structures. I need a data structure to hold profile records. Th...

How to get a tree structured table data by linq?

I have a table which has a tree structure in itself. Id ParentId Name ---------------- 1 null x 2 null y 3 null z 4 null t 5 1 xx 6 1 xy 7 1 xz 8 2 yx 9 2 yy 10 9 yyx 11 10 yyxx 12 11 yyxxx I want to retrieve the whole sub-tree under a root node. When my r...

What's a good data structure for building equivalence classes on nodes of a tree?

I'm looking for a good data structure to build equivalence classes on nodes of a tree. In an ideal structure, the following operations should be fast (O(1)/O(n) as appropriate) and easy (no paragraphs of mystery code): (A) Walk the tree from the root; on each node --> child transition enumerate all the equivalent versions of the child...

What is the degree of a tree? (As in, a tree ADT)

I understand that the degree of a node is the number of children it has. However, how do we define the degree of a tree? ...

writing a tree class in java

I want to construct a general tree in java in which one root node and which can have a n children and each node can contain sub trees. How do I get started? ...

How do I diff 2 source trees with a difference threshold?

Hi, I have 2 source trees, one is very similar to the other (one is VC6 and one is VS2005). I need a program that can recursively diff the source trees and tell me which files are different. However I want to be able to define 'how different' the files are. So I want to be able to ignore all files that are less than 5% different. I'd a...

Permuting a binary tree without the use of lists

I need to find an algorithm for generating every possible permutation of a binary tree, and need to do so without using lists (this is because the tree itself carries semantics and restraints that cannot be translated into lists). I've found an algorithm that works for trees with the height of three or less, but whenever I get to greater...