Hi Andre. 
You will fnd attached my files and a picture that illustrates the tree 
structure l'm looking for.
file 1 : somme comments on your codes
file 2 : my code to be improved.

For the part of your code. We should add child, number of child and data.
the structure seems to be appropriate from my point of view 

type MyNode{T}
    data:: T
    level::Int
    child :: Vector{MyNode}
    nchild :: Int
    nLeafs::Int
    leafs::Vector{MyNode}
end
 1) What's the purpose of this line  MyNode() = MyNode(0,0,MyNode[]) ?
2) for level 0 it's the root as you defined it :

root = MyNode(0,N, [MyNode() for i in 1:N])

but for level 1 it will be child :
child= MyNode(......)

for node in root.child
  # we have to link root to child and transferer data 
 # need to define function addEdge()


end

level 2 : 
leaf= MyNode(......)
 
for leaf in root.leaf
  # we have to link childs to their own leafs and transferer data 
 # need to define function addEdge()
end



On Wednesday, June 29, 2016 at 7:47:25 PM UTC+2, Andre Bieler wrote:
>
> Not very elegant, but maybe something like this?
>
> type MyNode
>     level::Int
>     nLeafs::Int
>     leafs::Vector{MyNode}
> end
>
> MyNode() = MyNode(0,0,MyNode[])
>
> N = 100
> root = MyNode(0,N, [MyNode() for i in 1:N])
>
> then you can go on and define the 1st level with a for loop and so on.
> Because it is only 3 levels I guess you can manually set it up, otherwise
> you want to use recursive functions or so.
>
> For 2nd level:
>
> for node in root.leafs
>   do_whatever
> end
>

Reply via email to