示例#1
0
        /// <summary>
        /// Récupère tous les enfants d'un noeud de manière récursive
        /// </summary>
        /// <param name="unusedMeetings">Les rendez-vous pas encore référencés dans l'arbre</param>
        /// <param name="end"></param>
        /// <returns></returns>
        private List<Node> getChildren(List<Meeting> unusedMeetings, Meeting end)
        {
            List<Node> children = new List<Node>();

            foreach (var meeting in unusedMeetings)
            {
                Node node = new Node();
                node.MeetingRef = meeting;
                if (unusedMeetings.Count <= 1)
                {
                    Node endNode = new Node();
                    endNode.MeetingRef = end;
                    endNode.Parent = node;
                    node.Children.Add(endNode);
                    _pathes.Add(endNode);
                }
                else
                {
                    List<Meeting> unusedMeetingsbis = new List<Meeting>();
                    unusedMeetingsbis.AddRange(unusedMeetings);
                    unusedMeetingsbis.Remove(meeting);
                    node.Children.AddRange(getChildren(unusedMeetingsbis, end));
                }
                children.Add(node);
                foreach(var child in node.Children)
                    child.Parent = node;
            }

            //unusedMeetings = null;
            return children;
        }
示例#2
0
        /// <summary>
        /// Construit un arbre équilibré et retourne le premier noeud, la racine.
        /// </summary>
        /// <returns>La racine de l'arbre équilibré</returns>
        private Node buildTree()
        {
            List<Meeting> meetingsWhithoutStartEnd = new List<Meeting>();
            meetingsWhithoutStartEnd.AddRange(_meetings.Where(o => o.IsLocationFail == false));
            meetingsWhithoutStartEnd.Remove(meetingsWhithoutStartEnd.First());
            meetingsWhithoutStartEnd.Remove(meetingsWhithoutStartEnd.Last());
            Meeting start = _meetings.First();
            Meeting end = _meetings.Last();

            Node tree = new Node();
            tree.MeetingRef = start;
            tree.Children.AddRange(getChildren(meetingsWhithoutStartEnd, end));
            foreach (var child in tree.Children)
                child.Parent = tree;

            return tree;
        }
示例#3
0
 /// <summary>
 /// Récupère les meetings d'un chemin possible dans l'arbre de manière récursive
 /// </summary>
 /// <param name="parents"></param>
 /// <param name="child"></param>
 private void getParent(Order parents, Node child)
 {
     parents.Add(child);
     if (child.Parent == null)
         return;
     getParent(parents, child.Parent);
 }