tree

search and replace DOM elements in Java

I'm looking for a way to write a search and replace method using W3C DOM to update a tree. I've thought about doing a breadth-first search as below, but can't think of how to do the in place replacement? import org.w3c.dom.Node; private Element tree; public void searchReplace(Node x, Node y){ Queue<Node> q = new LinkedList<Node>(...

Php: Generate ul-li tree from active directory results

I've got a result set from adLDAP of the form OU=LEAF1,OU=PARENT1,OU=ROOT,DC=datacenter,DC=local OU=PARENT1,OU=ROOT,DC=datacenter,DC=local OU=ROOT,DC=datacenter,DC=local OU=LEAF2,OU=CHILD,OU=PARENT2,OU=ROOT,DC=datacenter,DC=local OU=CHILD,OU=PARENT2,OU=ROOT,DC=datacenter,DC=local OU=PARENT2,OU=ROOT,DC=datacenter,DC=local Where each li...

How to retrieve the children categories without the children of those ones ?

Here is my statement : SELECT ( COUNT( parent.categoryName ) - ( sub_tree.depth +1 ) ) AS depth, CONCAT( REPEAT( '', ( COUNT( parent.categoryName ) - ( sub_tree.depth +1 ) ) ) , node.categoryName ) AS categoryName FROM Categories AS node, Categories AS parent, Categories AS sub_parent, ( SELECT node.categoryName, ( ...

Clojure: How to generate a 'trie'?

Given the following... (def inTree '((1 2) (1 2 3) (1 2 4 5 9) (1 2 4 10 15) (1 2 4 20 25))) How would you transform it to this trie? (def outTrie '(1 (2 () (3 ()) (4 (5 (9 ())) (10 (15 ())) (20 (25 ())))))) ...

How to parse an XML tree with DOMDocument ?

Hi, Here is my XML file : <?xml version="1.0" encoding="utf-8"?> <root> <category> <name>Category</name> <desc>Category</desc> <category> <name>Subcategory</name> <desc>Sub-category</desc> <category> <name>Subcategory</name> <des...

Built-in tree view for Django-Admin sites?

Why is there no built-in tree view in the Python Django framework? Isn't there an easy way to visualize a model when a class has an 1:n relation to itself? I know about some fancy google code projects to achieve that but I think there must be some common sense among the Django community to handle this common case. Any ideas? ...

Retrieving all the ancestors of a rdf:Class

Hi all, Imagine the following Taxonomy (acyclic & directed graph): <my:Eukaryota> <rdfs:subClassOf> <my:Organism>. <my:Mammal> <rdfs:subClassOf> <my:Eukaryota>. <my:Primate> <rdfs:subClassOf> <my:Mammal>. <my:HomoSapiens> <rdfs:subClassOf> <my:Primate>. <my:Bacteria> <rdfs:subClassOf> <my:Organism>. <my:Escherichia> <rdfs:subClassOf> <m...

Existing implementations of Trees in Java?

I'm looking for any implementation of a pure Tree data structure for Java (that aren't graphical ones in java.awt), preferably generic. With a generic tree I'd like to add elements that are not supposed to be sorted and do something like this: TreeNode anotherNode = new TreeNode(); node.add(anotherNode); …and then I'd like to traver...

Hashset vs Treeset

I've always loved trees, that nice O(n*lg(n)) and the tidyness of them. However, every software engineer I've ever known has asked me pointedly why I would use a treeset. From a CS background, I don't think it matters all that much which you use, and I don't care to mess around with hash functions and buckets (in the case of Java). In w...

Getting consistent menu tree data from menu tables in MySQL

Hi everybody, I have a tree / ancestor / query problem I'm not able to solve: I have a table holding menu data and a table containing all the ancestors of the menu: table menu table ancestors +-----+------------+--------+ +---------+--------------+-------+ | id | title | active | | menu_id | ancestor_id | l...

Traversing tree made from DefaultMutableTreeNode tree

We have a tree structure implemented using the DefaultMutableTreeNode specified in Java. Is there any way of traversing it, that is inbuilt? If not, please suggest other techniques. ...

Ocaml: Tree functions

Are there any modules or functions for dealing with trees? I have a type that looks like this: type t = Leaf of string (* todo: replace with 'a *) | Node of string * t list and I'm struggling to do insertion, removal of subtrees, etc. I've used the googles but can't find anything. ...

Can i use jquery to select a sub tree out of a xml tree?

hi guys, i'm totally new to jquery and i was looking around to see if this can be done. basically i have a xml tree structure that looks like this: <?xml version="1.0" encoding="utf-8" ?> <RecentTutorials> <Tutorial author="The Reddest"> <Title>Silverlight and the Netflix API</Title> <Categories> <Category>Tutorials</Cat...

Aggregates in Django templates

In a Django application, I want to display a multi-level (but fixed-depth) tree of model objects in table form. The HTML would look something like this: <tr><td rowspan="2">group 1</td><td>item 1.1</td></tr> <tr><td>item 1.2</td></tr> <tr><td rowspan="3">group 2</td><td>item 2.1</td></tr> <tr><td>item 2.2</td></tr> <tr><td>item 2.3</td>...

Enumerate search trees

According to this question the number of different search trees of a certain size is equal to a catalan number. Is it possible to enumerate those trees? That is, can someone implement the following two functions: Node* id2tree(int id); // return root of tree int tree2id(Node* root); // return id of tree (I ask because the binary co...

Set of numbers to a grid

I have a set of numbers which I need to put on a rectangular grid as dense as possible (=the area of a grid is minimal). For example if I have to put numbers 16, 31, and 63, I can put them into 2x2-grid 1 6 3 0. I think the best way to solve the problem for an arbitrary collection of numbers is to make some kind of net or tree which t...

css tree folders list with jquery progress bar

I have a tree of folders and I want to add a progress bar next to the folder name which is also an anchor. The progress bar div section is the jQuery UI progress bar div. The pblabel element should seat on top of the progress bar. The bar element is the progress bar itself with a variable width. <ul> <li> <a href="" style="displa...

Records to Tree

Hi Guys, A little advise please. I am trying to create a tree out of following rows of data: TOP Level1 NotLeaf Level1 Data1 leaf TOP Level11 NotLeaf Level11 Level2 NotLeaf Level11 Data4 leaf Level2 Data2 leaf Level2 Data3 leaf The last column shows whether a node is a leaf...

Duplicating a Jtree

I need to create a copy of an already existing tree , created using DefaultMutableTreeNode.[Edit] So, I have tried to assign the existing root node, to another DefaultMutableTreeNode.Ex: DefaultMutableTreeNode ABC = new DefaultMutableTreeNode(null); DefaultMutableTreeNode ABCcopy = new DefaultMutableTreeNode(null); ABCcopy=ABC; But th...

Adding HTML in a dojo Tree label

I have a dojo dijit.Tree, and I want to be able to put some html in the labels. To do this, I created an function called getCustomLabel and assigned it to the tree getLabel attribute: tree = new dijit.Tree({ model: aMOdel, showRoot: false, getLabel: getCustomLabel }); function...