Beispiel #1
0
        public void Run(int vertex = 0)
        {
            stopped = false;

            for (int i = 0; i < statuses.Count(); ++i)
            {
                statuses[i] = HandleStatus.NEW;
            }
            HandleVertexNotify(vertex);

            var container = fs.GetContainer();

            container.Clear();
            container.Add(vertex);

            statuses[vertex] = HandleStatus.IN_PROGRESS;

            while (container.Count() != 0)
            {
                var v = container.Peek();
                container.Remove();

                int[] vertices;
                graph.GetAdjVertices(v, out vertices);
                foreach (var el in vertices)
                {
                    HandleVertexNotify(el);

                    if (stopped)
                    {
                        return;
                    }

                    if (statuses[el] == HandleStatus.NEW)
                    {
                        statuses[el] = HandleStatus.IN_PROGRESS;
                        container.Add(el);
                    }
                }
                statuses[v] = HandleStatus.COMPLETED;
            }
        }