Пример #1
0
        /// <summary>
        /// Iterate all components of the vertexId.
        /// </summary>
        /// <param name="tree"> The MTG. </param>
        /// <param name="vertexId"> The vertex from which the iteration begins. </param>
        /// <returns> Iterator on components of the MTG starting from a vertex. </returns>
        public IEnumerable <int> MtgIterator(mtg tree, int vertexId)
        {
            Dictionary <int, bool> visited = new Dictionary <int, bool>();

            visited.Add(vertexId, true);

            int complexId = vertexId;

            int maxScale = tree.MaxScale();

            yield return(vertexId);

            foreach (int vertex in tree.ComponentRootsAtScale(complexId, maxScale))
            {
                foreach (int vid in IterativePreOrder(tree, vertex))
                {
                    foreach (int node in ScaleIterator(tree, vid, complexId, visited))
                    {
                        yield return(node);
                    }
                }
            }
        }