<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697</link>
    <title>MATLAB Central Newsreader - Tree data structure in MatLab</title>
    <description>Feed for thread: Tree data structure in MatLab</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 01 Nov 2009 17:23:04 -0500</pubDate>
      <title>Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#691303</link>
      <author>Yersinio Jimenez</author>
      <description>Hi every guys.&lt;br&gt;
&lt;br&gt;
Does any one know if there is some tree like data structure in MatLab?&lt;br&gt;
&lt;br&gt;
The questions is because some algorithms are more clear if you think in terms of tree data structure instead of matrix.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thanks in advance.&lt;br&gt;
Yersinio.</description>
    </item>
    <item>
      <pubDate>Sun, 01 Nov 2009 17:47:35 -0500</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#691310</link>
      <author>Rune Allnor</author>
      <description>On 1 Nov, 18:23, &quot;Yersinio Jimenez&quot; &amp;lt;yersin...@hotmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi every guys.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Does any one know if there is some tree like data structure in MatLab?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The questions is because some algorithms are more clear if you think in terms of tree data structure instead of matrix.&lt;br&gt;
&lt;br&gt;
There is no such thing in matlab, but you might get access to&lt;br&gt;
something like that from the java engine matlab is based on.&lt;br&gt;
&lt;br&gt;
Apart from that, the whole idea behind matlab (MATrix LABoratry)&lt;br&gt;
is to express absolutely everything in terms of matrices.&lt;br&gt;
&lt;br&gt;
Rune</description>
    </item>
    <item>
      <pubDate>Wed, 11 Nov 2009 14:14:05 -0500</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#693850</link>
      <author>jason </author>
      <description>are you looking for a structure?&lt;br&gt;
i.e. Data.Field1='apples'&lt;br&gt;
Data.Field2='oranges'?&lt;br&gt;
&lt;br&gt;
in that case look up struct</description>
    </item>
    <item>
      <pubDate>Sat, 12 Dec 2009 00:14:19 -0500</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#701756</link>
      <author>Yersinio Jimenez</author>
      <description>No, i'm not talking about structs. A have already works with that and are two very differents things.&lt;br&gt;
&lt;br&gt;
Thanks, for reply.</description>
    </item>
    <item>
      <pubDate>Sat, 12 Dec 2009 00:17:07 -0500</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#701757</link>
      <author>Yersinio Jimenez</author>
      <description>I will try with java tree data structure, but i belivie that it would have some implications in terms of performance.&lt;br&gt;
&lt;br&gt;
Thanks for your reply.&lt;br&gt;
&lt;br&gt;
Yersinio.</description>
    </item>
    <item>
      <pubDate>Sat, 12 Dec 2009 08:44:03 -0500</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#701792</link>
      <author>Bruno Luong</author>
      <description>I would argue a CELL having nested cells having nested cells etc ... are tree. The different is inserting or removal a branch/element is a costly operation (since Matlab does not provide a notion of pointers). &lt;br&gt;
&lt;br&gt;
This data structure can be also represented by STRUCT with nested STRUCT.&lt;br&gt;
&lt;br&gt;
I believe there are several FEX tools that do conversion back and forth between XML and STRUCT. I have used one of those and it works OK for my need, which do not do any intensive tree manipulation.&lt;br&gt;
&lt;br&gt;
But yes, basically, there is nothing exactly match TREE in Matlab.&lt;br&gt;
&lt;br&gt;
Bruno </description>
    </item>
    <item>
      <pubDate>Sat, 16 Jan 2010 23:27:02 -0500</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#708975</link>
      <author>Davis </author>
      <description>&quot;Yersinio Jimenez&quot; &amp;lt;yersinioj@hotmail.com&amp;gt; wrote in message &amp;lt;hckg5o$8t6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi every guys.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Does any one know if there is some tree like data structure in MatLab?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The questions is because some algorithms are more clear if you think in terms of tree data structure instead of matrix.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks in advance.&lt;br&gt;
&amp;gt; Yersinio.&lt;br&gt;
&lt;br&gt;
I couldn't find a 'tree' class either, although I've looked.  However, it should be possible to spin your own by implementing it using an object oriented approach. Here, you create a 'node' class (preferably inherited from the handle class), with a constructor and destructor, and properties that include links to other nodes. You then create a 'tree class' that inherits the properties of the node class and include methods for inserting and deleting nodes, one to walk the tree up and down from its root, etc. You could also include events and event listeners if the application calls for it.&lt;br&gt;
&lt;br&gt;
In principle this could be implemented using structures (although I wouldn't even want to try, since using the object oriented class-based approach would be much, much easier).  (Honesty alert: I haven't actually done this yet, but am working on it.) Comments welcome.</description>
    </item>
    <item>
      <pubDate>Sun, 17 Jan 2010 13:24:03 -0500</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#709033</link>
      <author>Derek O'Connor</author>
      <description>&quot;Yersinio Jimenez&quot; &amp;lt;yersinioj@hotmail.com&amp;gt; wrote in message &amp;lt;hckg5o$8t6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi every guys.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Does any one know if there is some tree like data structure in MatLab?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The questions is because some algorithms are more clear if you think in terms of tree data structure instead of matrix.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks in advance.&lt;br&gt;
&amp;gt; Yersinio.&lt;br&gt;
-------------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
The simplest tree data structure is an array of parent 'pointers'&lt;br&gt;
&lt;br&gt;
A tree with n nodes can be stored using two arrays : Node(1:n)&lt;br&gt;
stores node data such as name, geographical coordinates, etc.,&lt;br&gt;
and Parent(1:n), where Parent(i) contains an number in (1:n)&lt;br&gt;
which is the location of node i's parent in array Node(1:n).&lt;br&gt;
&lt;br&gt;
Example: Tree with 14 nodes labelled with letters of the alphabet&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1  2  3  4  5   6  7   8  9 10 11  12 13  14&lt;br&gt;
--------------------------------------------------------&lt;br&gt;
Node:   y  q   g  s   t   e  k   w  l   x   y    v   f   m&lt;br&gt;
Parent: 8  4   2  0  4   4 12  6  8  7   8  13   8   3&lt;br&gt;
&lt;br&gt;
The root of the tree is Node(4) = s because Parent(4) = 0.&lt;br&gt;
&lt;br&gt;
This data structure is fine if all you want to do is climb up the tree, otherwise you need a more complicated data structure. If you don't need node data omit array Node(1:n).&lt;br&gt;
&lt;br&gt;
Read Cormen, Leiserson, and Rivest : Intro. to Algorithms, or Aho and Ullman: Foundations of Computer Science&lt;br&gt;
&lt;br&gt;
&amp;nbsp;Derek O'Connor</description>
    </item>
    <item>
      <pubDate>Tue, 06 Jul 2010 21:09:05 -0400</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#760344</link>
      <author>Joao Henriques</author>
      <description>Derek's answer is the right one for Matlab, it may be strange for someone with a different background (eg. C++, Java) but the only way to deal with this sort of data structures is to re-interpret them in terms of vectors or matrices. Sometimes it's not obvious how to do so, and the result is very inefficient and hard to maintain code because you're trying to hammer foreign concepts into ML! This may change as OOP matures within ML (but IMO it's not there right now).&lt;br&gt;
&lt;br&gt;
You can keep your data structures tidy by using structs, I'll describe this at the end.&lt;br&gt;
&lt;br&gt;
For the tree structure, if the number of children is fixed (for example, a binary tree), a tree with N nodes can be represented with an Nx2 matrix, where each row has the indexes of the children of each node (0 if none). This makes it easier to traverse from the root.&lt;br&gt;
&lt;br&gt;
Another example is when dealing with general graphs. For a graph with N nodes and M arcs, you can store it as two length M vectors, &quot;heads&quot; and &quot;tails&quot; (an arc points from the head node to the tail node), with the indexes of the corresponding nodes. Node data is kept separately, typically in other length N vectors (or cell arrays if the data has different shapes). Notice that this can also store trees, as they're just graphs after all!&lt;br&gt;
&lt;br&gt;
Storing these vectors as structs to pass them around easily, I'd have a struct representing the arcs:&lt;br&gt;
arcs.tails = ...&lt;br&gt;
arcs.heads = ...&lt;br&gt;
arcs.costs = ...&lt;br&gt;
(etc etc)&lt;br&gt;
And another representing the nodes if necessary:&lt;br&gt;
nodes.names = ...</description>
    </item>
    <item>
      <pubDate>Wed, 23 Nov 2011 16:46:08 -0500</pubDate>
      <title>Re: Tree data structure in MatLab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264697#859338</link>
      <author>LESTER GARCIA</author>
      <description>&quot;Yersinio Jimenez&quot; &amp;lt;yersinioj@hotmail.com&amp;gt; wrote in message &amp;lt;hckg5o$8t6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi every guys.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Does any one know if there is some tree like data structure in MatLab?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The questions is because some algorithms are more clear if you think in terms of tree data structure instead of matrix.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks in advance.&lt;br&gt;
&amp;gt; Yersinio.&lt;br&gt;
&lt;br&gt;
Please Review this tutorial from matlab about Tree operations, &lt;br&gt;
maybe what you are looking for is in there.&lt;br&gt;
&lt;br&gt;
I know the post is from long time ago, but, maybe this comment will &lt;br&gt;
help to others who are asking the same question, dont you think?</description>
    </item>
  </channel>
</rss>

