示例#1
0
        public int Grade(BracketTree bracket)
        {
            var node1          = bracket.Find(Entrant1);
            var node2          = bracket.Find(Entrant2);
            var commonAncestor = node1;

            var found = false;

            while (!found && commonAncestor != null)
            {
                commonAncestor = commonAncestor.Parent;

                if (commonAncestor.Find(node2.Entrant.Value) != null)
                {
                    found = true;
                }
            }

            if (commonAncestor is null)
            {
                throw new InvalidOperationException("Common ancestor is null!");
            }

            return(((node1.Depth - commonAncestor.Depth) + (node2.Depth - commonAncestor.Depth)) * Scaling);
        }
        public int Grade(BracketTree bracket)
        {
            var nodes = new List <BracketNode>();

            nodes.Add(bracket.Root);

            int?minDepth = null;
            var maxDepth = 0;

            while (nodes.Count > 0)
            {
                var current = nodes[0];
                nodes.RemoveAt(0);

                if (current.IsLeaf)
                {
                    minDepth = current.Depth < minDepth || minDepth is null ? current.Depth : minDepth;
                    maxDepth = current.Depth > maxDepth ? current.Depth : maxDepth;
                }
                else
                {
                    if (current.Left is BracketNode left)
                    {
                        nodes.Add(left);
                    }
                    if (current.Right is BracketNode right)
                    {
                        nodes.Add(right);
                    }
                }
            }

            return(-Scaling * (maxDepth - minDepth.GetValueOrDefault() + 1));
        }
示例#3
0
 public int Grade(BracketTree bracket)
 {
     throw new System.NotImplementedException();
 }
示例#4
0
 public Optimizer(ConfigurationContext context, BracketTree bracket)
 {
     _context = context;
     _bracket = bracket;
 }
示例#5
0
 public int Grade(BracketTree bracket)
 {
     return(0);
 }