tree

Sorting by custom field and fetching whole tree from DB

Hello everyone, I am trying to do file browser in a tree form and have a problem to sort it somehow. I use PHP and MySQL for that. I've created mixed (nested set + adjacency) table 'element' with the following fields: element_id, left_key, right_key, level, parent_id, element_name, element_type (enum: 'folder','file'), element_size. ...

How to add a new node to a dijit.Tree

I want to add a new node to a dijit.ree as a sibling of the currently selected node. I've found sample code (I'm new to dojo) that adds a new item to the tree using the newItem method of ItemFileWriteStore, but the new item always appears at the bottom of the tree. How would I add to the store at a specified position, in particular the...

Calculating depth and descendants of tree

Can you guys help me with the algorithm to do these things? I have preorder, inorder, and postorder implemented, and I am given the hint to traverse the tree with one of these orders. I am using dotty to label (or "visit") the nodes. Depth is the number of edges from the root to the bottom leaf, so everytime I move, I add +1 to the dept...

How to get all objects with their children using django orm?

Hi, I got very simple hierarchical structure: every object can have 0 or 1 parent. There's no limit on how many children each object can have. So in my application I got such a model: class O(Model): name = CharField(max_length = 20) parent = ForeignKey('O', related_name = 'children') Now I would like to be able to fetch all obj...

Need help with Trees and matching

I have implemented the following data structure: class Node(object): """Rules: A node's child is ONLY an iterable of nodes A leaf node must NOT have children and MUST have word """ def __init__(self, tag, children=[], word=u""): assert isinstance(tag, unicode) and isinstance(word, unicode) self.tag=ta...

How to use dojo-tree node in php query

Hi, could someone explain how it is possible to extract a node label (instead of a value) from a dojo-tree and than use it in a (php) query? Thank you! ...

Git - tidying up a repo

Hi I have got my repo into a bit of a state and want to be able to work my way out of it The repo looks a bit like this (A1, B1, C1 etc are obviously commits) A1 ---- A2 ---- A3 ---- A4 ---- A5 ---- A6 ---- A7 ---- A8 / (from a remote repo) B1 ---- B2...

Where to find Javascript Tree Creator?

Hi, Do you know any Javascript Tree Creator that lets you add or remove nodes up to 3 levels deep? I'm currently using the jQuery treeview but is currently coding the add and remove of node items which is hard. Cheers, Mark ...

Estimating the size of a tree

I'd like to estimate the number of leaves in a large tree structure for which I can't visit every node exhaustively. Is this algorithm appropriate? Does it have a name? Also, please pedant if I am using any terms improperly. sum_trials = 0 num_trials = 0 WHILE time_is_not_up bits = 0 ptr = tree.root WHILE count(ptr.children)...

Turn database result into array

Hi everyone, I have just made the update/add/delete part for the "Closure table" way of organizing query hierarchical data that are shown on page 70 in this slideshare: http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back My database looks like this: Table Categories: ID Name 1 Top value 2 Sub v...

An Efficient data structure for Sorted List

I want to save my objects according to a key in the attributes of my object in a sorted fashion. Later on I'll access these objects sequentially from max key to min key. I'll do some search tasks as well. I consider to use either AVL tree or RB Tree. As far as i know they are nearly equivalent in theory(Both have O(logn)). But in practi...

Which applications use R-Trees?

Besides GIS applications, which other applications or libraries use R-trees and its variants? ...

Move node in Nested Sets tree

Hi everyone, I am working on an adjacency list with mySQL and can not (atleast by myself) do the thinking needed to make a decent enough query to be able to move a set of nodes (together with eventual children nodes) around. The table has following columns: id name left right Thanks a lot! ...

tree element in firefox sidebar with dynamic elements and click functionality

I have created an extension to show a sidebar in firefox. Now i need to display a tree like structure where the third level will be dynamic and loads a particular link on clicking. I know how to create the three level hierarchy but with static data.. heres the code <treechildren> <treeitem container="true" o...

Get HTML DOM with CSS

CSS can apply styles in elements through one ID, class or pseudo-selector, but I would like to get the HTML tree, something like in javascript: <script type = "text/javascript"> window.onload = function () { var div = document.getElementsByTagName ("div"); div[0].style.backgroundColor = "gray"; div[0].style....

Searching over a templated tree

So I have 2 interfaces: A node that can have children public interface INode { IEnumeration<INode> Children { get; } void AddChild(INode node); } And a derived "Data Node" that can have data associated with it public interface IDataNode<DataType> : INode { DataType Data; IDataNode<DataType> FindNode(DataType dt); } ...

Looking for a better design: A readonly in-memory cache mechanism

Hi all, I have a Category entity (class), which has zero or one parent Category and many child Categories -- it's a tree structure. The Category data is stored in a RDBMS, so for better performance, I want to load all categories and cache them in memory while launching the applicaiton. Our system can have plugins, and we allow the plug...

Flex: Data Grid within Tree structure

Hi, Is it possible to have a data grid within a tree structure in flex? Reverse of what advanced datagrid provides{where you can have a tree structure within a data grid}. ...

Getting a table's values into a tree

So, I have a table like such: id|root|kw1|kw2|kw3|kw4|kw5|name 1| A| B| C| D| E| F|fileA 2| A| B| | | | |fileB 3| B| C| D| E| | |fileC 4| A| B| | | | |fileD (several hundred rows...) And I need to get it into a tree like the following: *A *B -fileB -fileD *C *D *E *F -fil...

Algorithm for parsing a flat tree into a non-flat tree

I have the following flat tree: id name parent_id is_directory =========================================================== 50 app 0 1 31 controllers 50 1 11 application_controller.rb 31 0 46 models 50 ...