void drawRandomTree()
        {
            t=Tree.Generate(gen_type,
                            depth: tree_depth,
                            max_breadth: tree_breadth, // 40,100
                            num_first_children : -1,
                            max_nodes : -1);

            //t.root.Visible=false;

            depthMap=DepthMap.Generate(t.MaxDepth, rand);

            t.Root.Point.X = this.splitContainer1.Panel2.Width / 2;
            t.Root.Point.Y = this.splitContainer1.Panel2.Height / 2;

            radius = new PointF();
            radius.Y = (float)branch_radius;
            radius.X=radius.Y;

#if RADIAL
            t.LayoutRadial2D(radius, edge_length, layout_type, chkGrow.Checked);
#else
            t.LayoutTopDown2D(radius, edge_length, layout_type, chkGrow.Checked);
#endif

            Render();
        }
        void fsTreeRenderNode(Tree owner, TNode c)
        {
            if (owner.MaxDepth == 0) return;

            t = owner;
            t.Root.Point.X = this.splitContainer1.Panel2.Width / 2;
            t.Root.Point.Y = this.splitContainer1.Panel2.Height / 2;
            t.UpdateAttributes();
            depthMap = DepthMap.Generate(t.MaxDepth, rand);
#if RADIAL
            t.LayoutRadial2D(radius, edge_length, layout_type, chkGrow.Checked);
#else
            t.LayoutTopDown2D(radius, edge_length, layout_type, chkGrow.Checked);
#endif

            Redraw(false);
        }
        /// <summary>
        /// calculate colors for each depth
        /// </summary>
        /// <returns></returns>
        public static DepthMap Generate(int max_depth, Random rand)
        {
            var dm=new DepthMap();
            Color c;
            int r,g,b;
            int alpha=255;
            int min=30;
            int max=255;

            for(int depth=0; depth <= max_depth; depth++)
            {
                r=rand.Next(min,max);
                g=rand.Next(min,max);
                b=rand.Next(min,max);

                c=Color.FromArgb(alpha,r,g,b);

                if(!dm.map.ContainsValue(c))
                    dm.map.Add(depth,c);
            }

            return dm;
        }
        void Panel2_Click(object sender,EventArgs e)
        {
            if (t == null) return;

            TNode node;
            List<TNode> near;
            MouseEventArgs mouse = (MouseEventArgs)e;

            node = t.FindByPoint(mouse.Location, tolerance: node_diameter);
            
            if(node != null)
            {
                lblSelectedNode.Text = "node [" + node.Point.X + ", " + node.Point.Y + "]";

                // TREEIFY
                if (mouse.Button == MouseButtons.Left)
                {
                    TNode n;

                    n = new TNode(); /*
                    n = Tree.Generate(gen_type, depth: 1, max_breadth: 4).Root; // */

                    n.Level = node.Level + 1;
                    node.Children.Add(n);

                    t.UpdateAttributes();
                    depthMap = DepthMap.Generate(t.MaxDepth, rand);
                    t.LayoutRadial2D(radius, edge_length, layout_type, chkGrow.Checked);

                    Redraw();
                }
                // FIND NEIBOURS
                else if (mouse.Button == MouseButtons.Right)
                {
                    near = t.FindNearest(mouse.Location, radius: 100);
                    foreach (TNode n in near)
                    {
                        draw_circle(n.Point, Color.Green, Color.Cyan);
                    }
                }
            }
        }