Пример #1
0
            public void Execute_BFS()
            {
                BFSQueue.Enqueue(sourceVertex);
                Discovered.Add(sourceVertex.Id);
                Parent.Add(sourceVertex.Id, -1);

                while (BFSQueue.Count != 0)
                {
                    var current = BFSQueue.Dequeue();

                    ProcessVertex_Early(current);

                    Processed.Add(current.Id);

                    foreach (var node in current.AdjacencyList)
                    {
                        if (!Processed.Contains(node.Id))
                        {
                            ProcessEdge(current, node);
                        }

                        if (!Discovered.Contains(node.Id))
                        {
                            Discovered.Add(node.Id);
                            BFSQueue.Enqueue(node);

                            if (!Parent.ContainsKey(node.Id))
                            {
                                Parent[node.Id] = current.Id;
                            }
                            else
                            {
                                Console.WriteLine("We shouldn't be here during BFS");
                            }
                        }
                    }

                    ProcessVertex_Late(current);
                }
            }
Пример #2
0
 public List <Tech> GetAvailableTech(Settlement.Settlement settlement)
 {
     return(Tree.Technologies.Where(tech => !Discovered.Contains(tech) && tech.IsAvailable(settlement)).ToList());
 }