Exemple #1
0
        public void Expand()
        {
            if (Depth == 0 || Level == MaxDepth)
            {
                return;
            }

            var taskList = new List <Task>();

            foreach (var kvPair in Root.OutgoingEdges)
            {
                var node = kvPair.Key;
                if (MRegion.ObsoleteNodes.Contains(node.NodeID))
                {
                    continue;
                }
                if (Parent != null && Parent.NodeID == node.NodeID) // avoid cyclic relations
                {
                    continue;
                }

                var child = new PredictiveNode(RoadNetwork, node, kvPair.Value.Cost, Depth - 1,
                                               MaxDepth, Root, PredictiveRegions, MRegion);
                var distance = kvPair.Value.Distance;

                Children.Add(child.Root.NodeID, child);
                var task = Task.Factory.StartNew(() => child.Expand());
                taskList.Add(task);
            }

            Task.WaitAll(taskList.ToArray());
        }
 private void ExpandPredictiveTrees(ConcurrentDictionary <int, RegionalNode> newRegion)
 {
     PredictiveRegions = new ConcurrentDictionary <int, ConcurrentDictionary <int, List <PredictiveNode> > >();
     foreach (var kv in newRegion)
     {
         if (MRegion.ObsoleteNodes.Contains(kv.Value.NodeID))
         {
             continue;
         }
         GetRoadNetwork().Nodes.TryGetValue(kv.Value.NodeID, out var node);
         var predictiveNode = new PredictiveNode(GetRoadNetwork(), node, 0, Depth, Depth, null,
                                                 PredictiveRegions, MRegion);
         predictiveNode.Expand();
     }
 }