tree

finding loops in graph/tree

Possible Duplicate: Best algorithm for detecting cycles in a directed graph Hi Could sb tell which algoritym I should use to find a loop/cycle in graph or tree ? Maybe sb has a pseudocode or sth I could start with. ...

Creating a Tree from a List of Rectangles

This may be a silly question, but nothing comes to mind straight away. Given a list R of 2D rectangles (x, y, w, h) arranged so that any given rectangle is either fully inside or fully outside any other, what's the most efficient way to determine the immediately enclosing rectangle p of each rectangle in R? Currently I sort R by y then x...

php tree class/array structure to breadcrumbs

Basically i received an API SOAP response of a list of categories in an class format as in array kind of way with CatID, name, parentID, level. What is the best way to turn this into an array of breadcrumbs for each CatID. I want to try reduce the number of operation as the array will be created on the fly to populate a drop down me...

Constructively manipulating any value/object within a JSON tree of unknown depth

Hi, I have a JSON tree that contains nodes and children - the format is: jsonObject = { id:nodeid_1, children: [ { id:nodeid_2, children:[] }, { id:nodeid_3, children:[ { id:nodeid_4, children:[] }, { id:nodeid_5, children:[] } } } I don't know the depth of this tre...

Recursive MySQL query?

I have a set of data that's organized hierarchically that should be able to grow to an arbitrary size. I need to retrieve the entire tree, but I can't figure out how to do it with just SQL. My current solution is to create a temporary table and use a recursive function to successively query branches of the tree and then store the result ...

Select rows from table using tree order

I have table witch contains fields: id, parent_id, name (etc.) i want to order this table in "tree travel order" ie. id parent_id 1, 0 3, 1 5, 1 2, 0 8, 2 4, 0 9, 4 (...) in short describe: take root node, append all children, take next root node append children etc. ...

Best way to graphically represent a tree node in Qt

Hello, I'm trying to visualise a tree in Qt. So far, all my nodes consist of simple circles and based on QGraphicsItem class. But I need to display some text over every node, how can I "attach" a QLabel to my nodes? Thanks in advance. ...

C data structure to disk

Hi, How can I make a copy of a tree data structure in memory to disk in C programming language? ...

what is the purpose of the 'right' value in a nested tree?

If I'm looking for nested nodes of a parent, I'd query for children like this: parent.left < child.left This is always true though: child.right < parent.right So why do all examples I've found run a between query? thanks, Matt ...

Including files issue with relative paths on a linux system

Hi, I have the following directory tree structure: /index.php /code/inc/variables.php /code/inc/config.php index.php is the file that is called. On our development system in: /code/inc/variables.php, when I have the line: require_once("./code/inc/config.php"); it doesnt work and when I have: include_once('config.php'); it does...

What's the best way to prevent a Flex 4 Tree from collapsing?

I have a Flex 4 Tree that shows and outline of data. I want to prevent users from collapsing any of the nodes, i.e. so that the whole tree is always visible. What is the best way to do that? Can I prevent the relevant events, or should I make a skin that is ignorant of collapsed nodes? ...

Lisp is for List Processing. Is there a language for Tree Processing?

The name for Lisp derives from LISt Processing. Linked lists are the major data structure of Lisp languages, and Lisp source code is itself made up of lists. As a result, Lisp programs can manipulate source code as a data structure (this is known as homoiconicity). However, a list is by definition a sequential construct. This encourages...

Visual C++'s implementation of std::map

How is std::map implemented in Visual C++? I know that some tree data structures just flag nodes as deleted when they are removed, instead of removing them right away. I need to make sure that my elements are never compared to elements which are no longer in the map. EDIT: I know that the implementation is probably correct wrt. the co...

MVC DropDown Tree select?

Hi! Im looking for a DropDown Tree Select. I have looked at this Tree control, but im not sure how to combind this with a dropdown button where the selected values are shown in the button when not expanded? BestRegards SowJim Edit : Dropdown tree looks somthing like this : ...

Android controls for navigation in a tree hierarchy

I want to navigate items in a tree hierarchy. I put the items on the same level in a listview. Upon clicking the item in the listview it will open another listview to show the items in the child level. I want the user to navigate easily to another level (parent, grandparent, grandgrandparent) without pressing the back buttons several t...

Creating a nested set with sqlite and Objective-c

I was struggling with nested sets, specifically building one on the iPhone using sqlite. I found a handy script that I then adapted from PHP. It basically sets the left and right values based on parent ids. So you need a table where each entry has an 'id' and a 'pid' as well as 'lft' and 'rgt'. I find it easy to map the ids to their re...

Locating all reachable nodes using SQL

Suppose a table with two columns: From and To. Example: From To 1 2 2 3 2 4 4 5 I would like to know the most effective way to locate all nodes that are reachable from a node using a SQL Query. Example: given 1 it would return 2,3,4 and 5. It is possible to use several queries united by UNION clauses but it would limit the...

How to use a generator to iterate over a tree's leafs

The problem: I have a trie and I want to return the information stored in it. Some leaves have information (set as value > 0) and some leaves do not. I would like to return only those leaves that have a value. As in all trie's number of leaves on each node is variable, and the key to each value is actually made up of the path necessary...

Populating tree in flex using array

Hi my required tree structure is as follows a -- b -- d | | | | | -- e -- c I have my string array as follows a/b,c b/d,e d/ e where the component before / represents parent and the children of the corresponding parent are separated by , Can anyone provide me the logic to create a array collection for this hierarch...

How can iterative deepening search implemented efficient in haskell?

I have an optimization problem I want to solve. You have some kind of data-structure: data Foo = { fooA :: Int , fooB :: Int , fooC :: Int , fooD :: Int , fooE :: Int } and a rating function: rateFoo :: myFoo -> Int I have to optimize the result of rateFoo by changing the values in the struct. In this specific case, I dec...