private static double GetFullness(IInformationTreeNode node, uint depth) { var sum = node.Children?.Sum(child => GetFullness((IInformationTreeNode)child, depth + 1)); return(sum != null ? node.Value / Math.Pow(2, depth) + (double)sum : -1); }
/// <summary> /// Calculates the value of a node relative to the associated root node. /// </summary> /// <param name="node">The node whose relative value we want to calculate.</param> /// <returns>The value of a node relative to the associated root node.</returns> public static double GetRelativeValue(this IInformationTreeNode node) { return((double)node.Value / node.RootNode.Value); }