Exemplo n.º 1
0
        internal static int igraph_pagerank(igraph_t graph, igraph_pagerank_algo_t algo, igraph_vector_t vector, out double value, igraph_vs_t vids, bool directed, double damping, igraph_vector_t weights)
        {
            value = 1;
            var options = IntPtr.Zero;

            if (algo == igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_ARPACK)
            {
                var arpackoptions = GetDefaultArpackOptions();
                options = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(igraph_arpack_options_t)));
                Marshal.StructureToPtr(arpackoptions, options, false);
            }
            else if (algo == igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_POWER)
            {
                var poweroptions = GetDefaultPowerOptions();
                options = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(igraph_pagerank_power_options_t)));
                Marshal.StructureToPtr(poweroptions, options, false);
            }
            try {
                return(X86 ? igraph_pagerank_x86(graph, algo, vector, ref value, vids, directed, damping, weights, options) : igraph_pagerank_x64(graph, algo, vector, ref value, vids, directed, damping, weights, options));
            } finally {
                if (algo == igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_ARPACK)
                {
                    Marshal.DestroyStructure(options, typeof(igraph_arpack_options_t));
                    Marshal.FreeHGlobal(options);
                }
                else if (algo == igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_POWER)
                {
                    Marshal.DestroyStructure(options, typeof(igraph_pagerank_power_options_t));
                    Marshal.FreeHGlobal(options);
                }
            }
        }
Exemplo n.º 2
0
 private static extern int igraph_pagerank_x64(igraph_t graph, igraph_pagerank_algo_t algo, [In, Out] igraph_vector_t vector, ref double value, igraph_vs_t vids, bool directed, double damping, igraph_vector_t weights, IntPtr options);