예제 #1
0
        /// <summary>
        /// Sorts the vertices in the given graph based on a hilbert curve.
        /// </summary>
        /// <typeparam name="TEdgeData"></typeparam>
        /// <param name="graph"></param>
        /// <param name="n"></param>
        public static void SortHilbert <TEdgeData>(this GraphBase <TEdgeData> graph, int n)
            where TEdgeData : struct, IGraphEdgeData
        {
            if (graph == null)
            {
                throw new ArgumentNullException("graph");
            }
            if (graph.VertexCount == 1)
            {
                return;
            }

            uint left  = 1;
            uint right = graph.VertexCount;

            IGraphExtensions.SortHilbert(graph, n, left, right);
        }
예제 #2
0
        /// <summary>
        /// Sorts the vertices in the given graph based on a hilbert curve.
        /// </summary>
        /// <typeparam name="TEdgeData"></typeparam>
        /// <param name="graph"></param>
        /// <param name="n"></param>
        private static void SortHilbert <TEdgeData>(GraphBase <TEdgeData> graph, int n, uint left, uint right)
            where TEdgeData : struct, IGraphEdgeData
        {
            if (graph == null)
            {
                throw new ArgumentNullException("graph");
            }
            if (graph.VertexCount == 1)
            {
                return;
            }

            if (left < right)
            { // left is still to the left.
                uint pivot = IGraphExtensions.SortHilbertPartition(graph, n, left, right);
                if (left <= pivot && pivot <= right)
                {
                    IGraphExtensions.SortHilbert(graph, n, left, pivot - 1);
                    IGraphExtensions.SortHilbert(graph, n, pivot, right);
                }
            }
        }