Ejemplo n.º 1
0
        /// <summary>
        /// Copies all data from the given graph.
        /// </summary>
        /// <typeparam name="TEdgeData"></typeparam>
        public static void SortHilbert <TEdgeData>(this GraphBase <TEdgeData> graph, int n, Action <uint, uint> transform)
            where TEdgeData : struct, IGraphEdgeData
        {
            // build ranks.
            var ranks = graph.BuildHilbertRank(n);

            // invert ranks.
            var transformations = new HugeArray <uint>(ranks.Length);

            for (uint i = 0; i < ranks.Length; i++)
            {
                if (transform != null)
                {
                    transform(ranks[i], i);
                }
                transformations[ranks[i]] = i;
            }

            // copy from the given graph but with sorted vertices.
            graph.Sort(transformations);
        }
        /// <summary>
        /// Sorts the graph based on the given transformations.
        /// </summary>
        public override void Sort(HugeArrayBase <uint> transformations)
        {
            _reverseDirectNeighbours = null;

            _graph.Sort(transformations);
        }