Example #1
0
        private static Graph AddToGraph <TBounds, TPayload>(this BalancedBoundingTree <TBounds, TPayload> .BalancedBoundingNode node, Graph graph, int depth)
            where TBounds : IComparable <TBounds>, IEquatable <TBounds>
        {
            if (!ReferenceEquals(node.LowerTree, BalancedBoundingTree <TBounds, TPayload> .Nil))
            {
                graph = graph.Add(EdgeStatement.For(node.ToString(), node.LowerTree.ToString()));
                if (depth > 0)
                {
                    graph = node.LowerTree.AddToGraph(graph, depth - 1);
                }
            }

            if (!ReferenceEquals(node.UpperTree, BalancedBoundingTree <TBounds, TPayload> .Nil))
            {
                graph = graph.Add(EdgeStatement.For(node.ToString(), node.UpperTree.ToString()));
                if (depth > 0)
                {
                    graph = node.UpperTree.AddToGraph(graph, depth - 1);
                }
            }

            return(graph);
        }