Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Igraph/0.8.0-pre/HeuristicLab.Igraph-0.8.0-pre/DllImporter.cs @ 14245

Last change on this file since 14245 was 14245, checked in by abeham, 8 years ago

#2651: worked on igraph integration

File size: 27.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Runtime.InteropServices;
24
25namespace HeuristicLab.IGraph {
26  internal static class DllImporter {
27    private const string X86Dll = "igraph-0.8.0-pre-x86.dll";
28    private const string X64Dll = "igraph-0.8.0-pre-x64.dll";
29    private readonly static bool X86 = false;
30
31    static DllImporter() {
32      X86 = !Environment.Is64BitProcess;
33    }
34
35    #region igraph
36    #region igraph init/finalize
37    internal static void igraph_empty(igraph_t graph, int n, bool directed) {
38      if (X86) igraph_empty_x86(graph, n, directed);
39      else igraph_empty_x64(graph, n, directed);
40    }
41    internal static int igraph_destroy(igraph_t graph) {
42      return X86 ? igraph_destroy_x86(graph) : igraph_destroy_x64(graph);
43    }
44    #endregion
45
46    #region igraph query
47    internal static int igraph_vcount(igraph_t graph) {
48      return X86 ? igraph_vcount_x86(graph) : igraph_vcount_x64(graph);
49    }
50    #endregion
51
52    #region igraph characteristics
53    internal static int igraph_density(igraph_t graph, out double density, bool loops) {
54      density = double.NaN;
55      return X86 ? igraph_density_x86(graph, ref density, loops) : igraph_density_x64(graph, ref density, loops);
56    }
57
58    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) {
59      value = 1;
60      var options = IntPtr.Zero;
61      if (algo == igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_ARPACK) {
62        var arpackoptions = GetDefaultArpackOptions();
63        options = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(igraph_arpack_options_t)));
64        Marshal.StructureToPtr(arpackoptions, options, false);
65      } else if (algo == igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_POWER) {
66        var poweroptions = GetDefaultPowerOptions();
67        options = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(igraph_pagerank_power_options_t)));
68        Marshal.StructureToPtr(poweroptions, options, false);
69      }
70      try {
71        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);
72      } finally {
73        if (algo == igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_ARPACK) {
74          Marshal.DestroyStructure(options, typeof(igraph_arpack_options_t));
75          Marshal.FreeHGlobal(options);
76        } else if (algo == igraph_pagerank_algo_t.IGRAPH_PAGERANK_ALGO_POWER) {
77          Marshal.DestroyStructure(options, typeof(igraph_pagerank_power_options_t));
78          Marshal.FreeHGlobal(options);
79        }
80      }
81    }
82
83    unsafe private static igraph_arpack_options_t GetDefaultArpackOptions() {
84      var arpackoptions = new igraph_arpack_options_t();
85      arpackoptions.bmat[0] = 'I';
86      arpackoptions.which[0] = arpackoptions.which[1] = 'X';
87      arpackoptions.nev = 1;
88      arpackoptions.ishift = 1;
89      arpackoptions.mxiter = 1000;
90      arpackoptions.nb = 1;
91      arpackoptions.mode = 1;
92      arpackoptions.iparam[0] = arpackoptions.ishift;
93      arpackoptions.iparam[1] = arpackoptions.iparam[4] = arpackoptions.iparam[5] = arpackoptions.iparam[7] = arpackoptions.iparam[8] = arpackoptions.iparam[9] = arpackoptions.iparam[10] = 0;
94      arpackoptions.iparam[2] = arpackoptions.mxiter;
95      arpackoptions.iparam[3] = arpackoptions.nb;
96      arpackoptions.iparam[6] = arpackoptions.mode;
97      return arpackoptions;
98    }
99
100    private static igraph_pagerank_power_options_t GetDefaultPowerOptions() {
101      var poweroptions = new igraph_pagerank_power_options_t();
102      poweroptions.niter = 50;
103      poweroptions.eps = 1e-5;
104      return poweroptions;
105    }
106    #endregion
107
108    #region igraph manipulation
109    internal static int igraph_add_edge(igraph_t graph, int from, int to) {
110      return X86 ? igraph_add_edge_x86(graph, from, to) : igraph_add_edge_x64(graph, from, to);
111    }
112    #endregion
113
114    #region Platform specific DLL imports
115    [DllImport(X86Dll, EntryPoint = "igraph_empty", CallingConvention = CallingConvention.Cdecl)]
116    private static extern void igraph_empty_x86([In, Out]igraph_t graph, int n, bool directed);
117    [DllImport(X64Dll, EntryPoint = "igraph_empty", CallingConvention = CallingConvention.Cdecl)]
118    private static extern void igraph_empty_x64([In, Out]igraph_t graph, int n, bool directed);
119    [DllImport(X86Dll, EntryPoint = "igraph_destroy", CallingConvention = CallingConvention.Cdecl)]
120    private static extern int igraph_destroy_x86([In, Out]igraph_t graph);
121    [DllImport(X64Dll, EntryPoint = "igraph_destroy", CallingConvention = CallingConvention.Cdecl)]
122    private static extern int igraph_destroy_x64([In, Out]igraph_t graph);
123    [DllImport(X86Dll, EntryPoint = "igraph_vcount", CallingConvention = CallingConvention.Cdecl)]
124    private static extern int igraph_vcount_x86(igraph_t graph);
125    [DllImport(X64Dll, EntryPoint = "igraph_vcount", CallingConvention = CallingConvention.Cdecl)]
126    private static extern int igraph_vcount_x64(igraph_t graph);
127    [DllImport(X86Dll, EntryPoint = "igraph_add_edge", CallingConvention = CallingConvention.Cdecl)]
128    private static extern int igraph_add_edge_x86([In, Out]igraph_t graph, int from, int to);
129    [DllImport(X64Dll, EntryPoint = "igraph_add_edge", CallingConvention = CallingConvention.Cdecl)]
130    private static extern int igraph_add_edge_x64([In, Out]igraph_t graph, int from, int to);
131    [DllImport(X86Dll, EntryPoint = "igraph_density", CallingConvention = CallingConvention.Cdecl)]
132    private static extern int igraph_density_x86(igraph_t graph, ref double density, bool loops);
133    [DllImport(X64Dll, EntryPoint = "igraph_density", CallingConvention = CallingConvention.Cdecl)]
134    private static extern int igraph_density_x64(igraph_t graph, ref double density, bool loops);
135    [DllImport(X86Dll, EntryPoint = "igraph_pagerank", CallingConvention = CallingConvention.Cdecl)]
136    private static extern int igraph_pagerank_x86(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);
137    [DllImport(X64Dll, EntryPoint = "igraph_pagerank", CallingConvention = CallingConvention.Cdecl)]
138    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);
139    #endregion
140    #endregion
141
142    #region igraph_rng
143    internal static int igraph_rng_get_integer(int l, int h) {
144      return X86 ? igraph_rng_get_integer_x86(igraph_rng_default_x86(), l, h) : igraph_rng_get_integer_x64(igraph_rng_default_x64(), l, h);
145    }
146    internal static int igraph_rng_seed(uint seed) {
147      return X86 ? igraph_rng_seed_x86(igraph_rng_default_x86(), seed) : igraph_rng_seed_x64(igraph_rng_default_x64(), seed);
148    }
149
150    #region Platform specific DLL imports
151    [DllImport(X86Dll, EntryPoint = "igraph_rng_default", CallingConvention = CallingConvention.Cdecl)]
152    private static extern IntPtr igraph_rng_default_x86();
153    [DllImport(X64Dll, EntryPoint = "igraph_rng_default", CallingConvention = CallingConvention.Cdecl)]
154    private static extern IntPtr igraph_rng_default_x64();
155    [DllImport(X86Dll, EntryPoint = "igraph_rng_get_integer", CallingConvention = CallingConvention.Cdecl)]
156    private static extern int igraph_rng_get_integer_x86(IntPtr rng, int l, int h);
157    [DllImport(X64Dll, EntryPoint = "igraph_rng_get_integer", CallingConvention = CallingConvention.Cdecl)]
158    private static extern int igraph_rng_get_integer_x64(IntPtr rng, int l, int h);
159    [DllImport(X86Dll, EntryPoint = "igraph_rng_seed", CallingConvention = CallingConvention.Cdecl)]
160    private static extern int igraph_rng_seed_x86(IntPtr rng, uint seed);
161    [DllImport(X64Dll, EntryPoint = "igraph_rng_seed", CallingConvention = CallingConvention.Cdecl)]
162    private static extern int igraph_rng_seed_x64(IntPtr rng, uint seed);
163    #endregion
164    #endregion
165
166    #region igraph_vector
167    internal static int igraph_vector_init(igraph_vector_t vector, int length) {
168      return X86 ? igraph_vector_init_x86(vector, length) : igraph_vector_init_x64(vector, length);
169    }
170    internal static int igraph_vector_init_copy(igraph_vector_t vector, double[] vec) {
171      return X86 ? igraph_vector_init_copy_x86(vector, vec, vec.Length) : igraph_vector_init_copy_x64(vector, vec, vec.Length);
172    }
173    internal static void igraph_vector_destroy(igraph_vector_t vector) {
174      if (X86) igraph_vector_destroy_x86(vector);
175      else igraph_vector_destroy_x64(vector);
176    }
177    internal static int igraph_vector_copy(igraph_vector_t to, igraph_vector_t from) {
178      return X86 ? igraph_vector_copy_x86(to, from) : igraph_vector_copy_x64(to, from);
179    }
180    internal static double[] igraph_vector_to_array(igraph_vector_t from) {
181      var len = igraph_vector_size(from);
182      var result = new double[len];
183      if (X86) igraph_vector_copy_to_x86(from, result);
184      else igraph_vector_copy_to_x64(from, result);
185      return result;
186    }
187
188    internal static int igraph_vector_size(igraph_vector_t vector) {
189      return X86 ? igraph_vector_size_x86(vector) : igraph_vector_size_x64(vector);
190    }
191
192    internal static double igraph_vector_e(igraph_vector_t vector, int index) {
193      return X86 ? igraph_vector_e_x86(vector, index) : igraph_vector_e_x64(vector, index);
194    }
195
196    internal static void igraph_vector_set(igraph_vector_t vector, int index, double value) {
197      if (X86) igraph_vector_set_x86(vector, index, value);
198      else igraph_vector_set_x64(vector, index, value);
199    }
200    internal static void igraph_vector_fill(igraph_vector_t vector, double v) {
201      if (X86) igraph_vector_fill_x86(vector, v);
202      else igraph_vector_fill_x64(vector, v);
203    }
204    internal static void igraph_vector_scale(igraph_vector_t vector, double by) {
205      if (X86) igraph_vector_scale_x86(vector, by);
206      else igraph_vector_scale_x64(vector, by);
207    }
208
209    internal static int igraph_vector_reverse(igraph_vector_t vector) {
210      return X86 ? igraph_vector_reverse_x86(vector) : igraph_vector_reverse_x64(vector);
211    }
212    internal static int igraph_vector_shuffle(igraph_vector_t vector) {
213      return X86 ? igraph_vector_shuffle_x86(vector) : igraph_vector_shuffle_x64(vector);
214    }
215
216    #region Platform specific DLL imports
217    [DllImport(X86Dll, EntryPoint = "igraph_vector_init", CallingConvention = CallingConvention.Cdecl)]
218    private static extern int igraph_vector_init_x86([In, Out]igraph_vector_t vector, int length);
219    [DllImport(X64Dll, EntryPoint = "igraph_vector_init", CallingConvention = CallingConvention.Cdecl)]
220    private static extern int igraph_vector_init_x64([In, Out]igraph_vector_t vector, int length);
221    [DllImport(X86Dll, EntryPoint = "igraph_vector_init_copy", CallingConvention = CallingConvention.Cdecl)]
222    private static extern int igraph_vector_init_copy_x86([In, Out]igraph_vector_t vector, double[] vec, int length);
223    [DllImport(X64Dll, EntryPoint = "igraph_vector_init_copy", CallingConvention = CallingConvention.Cdecl)]
224    private static extern int igraph_vector_init_copy_x64([In, Out]igraph_vector_t vector, double[] vec, int length);
225    [DllImport(X86Dll, EntryPoint = "igraph_vector_destroy", CallingConvention = CallingConvention.Cdecl)]
226    private static extern void igraph_vector_destroy_x86([In, Out]igraph_vector_t vector);
227    [DllImport(X64Dll, EntryPoint = "igraph_vector_destroy", CallingConvention = CallingConvention.Cdecl)]
228    private static extern void igraph_vector_destroy_x64([In, Out]igraph_vector_t vector);
229    [DllImport(X86Dll, EntryPoint = "igraph_vector_size", CallingConvention = CallingConvention.Cdecl)]
230    private static extern int igraph_vector_size_x86(igraph_vector_t vector);
231    [DllImport(X64Dll, EntryPoint = "igraph_vector_size", CallingConvention = CallingConvention.Cdecl)]
232    private static extern int igraph_vector_size_x64(igraph_vector_t vector);
233    [DllImport(X86Dll, EntryPoint = "igraph_vector_e", CallingConvention = CallingConvention.Cdecl)]
234    private static extern double igraph_vector_e_x86(igraph_vector_t vector, int index);
235    [DllImport(X64Dll, EntryPoint = "igraph_vector_e", CallingConvention = CallingConvention.Cdecl)]
236    private static extern double igraph_vector_e_x64(igraph_vector_t vector, int index);
237    [DllImport(X86Dll, EntryPoint = "igraph_vector_set", CallingConvention = CallingConvention.Cdecl)]
238    private static extern double igraph_vector_set_x86([In, Out]igraph_vector_t vector, int index, double value);
239    [DllImport(X64Dll, EntryPoint = "igraph_vector_set", CallingConvention = CallingConvention.Cdecl)]
240    private static extern double igraph_vector_set_x64([In, Out]igraph_vector_t vector, int index, double value);
241    [DllImport(X86Dll, EntryPoint = "igraph_vector_copy", CallingConvention = CallingConvention.Cdecl)]
242    private static extern int igraph_vector_copy_x86([In, Out]igraph_vector_t to, igraph_vector_t from);
243    [DllImport(X64Dll, EntryPoint = "igraph_vector_copy", CallingConvention = CallingConvention.Cdecl)]
244    private static extern int igraph_vector_copy_x64([In, Out]igraph_vector_t to, igraph_vector_t from);
245    [DllImport(X86Dll, EntryPoint = "igraph_vector_copy_to", CallingConvention = CallingConvention.Cdecl)]
246    private static extern void igraph_vector_copy_to_x86(igraph_vector_t from, [In, Out]double[] to);
247    [DllImport(X64Dll, EntryPoint = "igraph_vector_copy", CallingConvention = CallingConvention.Cdecl)]
248    private static extern void igraph_vector_copy_to_x64(igraph_vector_t from, [In, Out]double[] to);
249    [DllImport(X86Dll, EntryPoint = "igraph_vector_fill", CallingConvention = CallingConvention.Cdecl)]
250    private static extern int igraph_vector_fill_x86([In, Out]igraph_vector_t vector, double v);
251    [DllImport(X64Dll, EntryPoint = "igraph_vector_fill", CallingConvention = CallingConvention.Cdecl)]
252    private static extern int igraph_vector_fill_x64([In, Out]igraph_vector_t vector, double v);
253    [DllImport(X86Dll, EntryPoint = "igraph_vector_reverse", CallingConvention = CallingConvention.Cdecl)]
254    private static extern int igraph_vector_reverse_x86([In, Out]igraph_vector_t vector);
255    [DllImport(X64Dll, EntryPoint = "igraph_vector_reverse", CallingConvention = CallingConvention.Cdecl)]
256    private static extern int igraph_vector_reverse_x64([In, Out]igraph_vector_t vector);
257    [DllImport(X86Dll, EntryPoint = "igraph_vector_shuffle", CallingConvention = CallingConvention.Cdecl)]
258    private static extern int igraph_vector_shuffle_x86([In, Out]igraph_vector_t vector);
259    [DllImport(X64Dll, EntryPoint = "igraph_vector_shuffle", CallingConvention = CallingConvention.Cdecl)]
260    private static extern int igraph_vector_shuffle_x64([In, Out]igraph_vector_t vector);
261    [DllImport(X86Dll, EntryPoint = "igraph_vector_scale", CallingConvention = CallingConvention.Cdecl)]
262    private static extern void igraph_vector_scale_x86([In, Out]igraph_vector_t vector, double by);
263    [DllImport(X64Dll, EntryPoint = "igraph_vector_scale", CallingConvention = CallingConvention.Cdecl)]
264    private static extern void igraph_vector_scale_x64([In, Out]igraph_vector_t vector, double by);
265    #endregion
266    #endregion
267
268    #region igraph_matrix
269    internal static int igraph_matrix_init(igraph_matrix_t matrix, int nrows, int ncols) {
270      return X86 ? igraph_matrix_init_x86(matrix, nrows, ncols) : igraph_matrix_init_x64(matrix, nrows, ncols);
271    }
272    internal static void igraph_matrix_destroy(igraph_matrix_t matrix) {
273      if (X86) igraph_matrix_destroy_x86(matrix);
274      else igraph_matrix_destroy_x64(matrix);
275    }
276    internal static int igraph_matrix_copy(igraph_matrix_t to, igraph_matrix_t from) {
277      return X86 ? igraph_matrix_copy_x86(to, from) : igraph_matrix_copy_x64(to, from);
278    }
279
280    internal static double igraph_matrix_e(igraph_matrix_t matrix, int row, int col) {
281      return X86 ? igraph_matrix_e_x86(matrix, row, col) : igraph_matrix_e_x64(matrix, row, col);
282    }
283
284    internal static void igraph_matrix_set(igraph_matrix_t matrix, int row, int col, double value) {
285      if (X86) igraph_matrix_set_x86(matrix, row, col, value);
286      else igraph_matrix_set_x64(matrix, row, col, value);
287    }
288
289    internal static void igraph_matrix_fill(igraph_matrix_t matrix, double v) {
290      if (X86) igraph_matrix_fill_x86(matrix, v);
291      else igraph_matrix_fill_x64(matrix, v);
292    }
293
294    internal static int igraph_matrix_transpose(igraph_matrix_t matrix) {
295      return X86 ? igraph_matrix_transpose_x86(matrix) : igraph_matrix_transpose_x64(matrix);
296    }
297
298    internal static void igraph_matrix_scale(igraph_matrix_t matrix, double by) {
299      if (X86) igraph_matrix_scale_x86(matrix, by);
300      else igraph_matrix_scale_x64(matrix, by);
301    }
302
303    #region Platform specific DLL imports
304    [DllImport(X86Dll, EntryPoint = "igraph_matrix_init", CallingConvention = CallingConvention.Cdecl)]
305    private static extern int igraph_matrix_init_x86([In, Out]igraph_matrix_t matrix, int nrow, int ncol);
306    [DllImport(X64Dll, EntryPoint = "igraph_matrix_init", CallingConvention = CallingConvention.Cdecl)]
307    private static extern int igraph_matrix_init_x64([In, Out]igraph_matrix_t matrix, int nrow, int ncol);
308    [DllImport(X86Dll, EntryPoint = "igraph_matrix_destroy", CallingConvention = CallingConvention.Cdecl)]
309    private static extern void igraph_matrix_destroy_x86([In, Out]igraph_matrix_t matrix);
310    [DllImport(X64Dll, EntryPoint = "igraph_matrix_destroy", CallingConvention = CallingConvention.Cdecl)]
311    private static extern void igraph_matrix_destroy_x64([In, Out]igraph_matrix_t matrix);
312    [DllImport(X86Dll, EntryPoint = "igraph_matrix_e", CallingConvention = CallingConvention.Cdecl)]
313    private static extern double igraph_matrix_e_x86(igraph_matrix_t matrix, int row, int col);
314    [DllImport(X64Dll, EntryPoint = "igraph_matrix_e", CallingConvention = CallingConvention.Cdecl)]
315    private static extern double igraph_matrix_e_x64(igraph_matrix_t matrix, int row, int col);
316    [DllImport(X86Dll, EntryPoint = "igraph_matrix_set", CallingConvention = CallingConvention.Cdecl)]
317    private static extern double igraph_matrix_set_x86([In, Out]igraph_matrix_t matrix, int row, int col, double value);
318    [DllImport(X64Dll, EntryPoint = "igraph_matrix_set", CallingConvention = CallingConvention.Cdecl)]
319    private static extern double igraph_matrix_set_x64([In, Out]igraph_matrix_t matrix, int row, int col, double value);
320    [DllImport(X86Dll, EntryPoint = "igraph_matrix_copy", CallingConvention = CallingConvention.Cdecl)]
321    private static extern int igraph_matrix_copy_x86([In, Out]igraph_matrix_t to, igraph_matrix_t from);
322    [DllImport(X64Dll, EntryPoint = "igraph_matrix_copy", CallingConvention = CallingConvention.Cdecl)]
323    private static extern int igraph_matrix_copy_x64([In, Out]igraph_matrix_t to, igraph_matrix_t from);
324    [DllImport(X86Dll, EntryPoint = "igraph_matrix_fill", CallingConvention = CallingConvention.Cdecl)]
325    private static extern void igraph_matrix_fill_x86([In, Out]igraph_matrix_t matrix, double v);
326    [DllImport(X64Dll, EntryPoint = "igraph_matrix_fill", CallingConvention = CallingConvention.Cdecl)]
327    private static extern void igraph_matrix_fill_x64([In, Out]igraph_matrix_t matrix, double v);
328    [DllImport(X86Dll, EntryPoint = "igraph_matrix_transpose", CallingConvention = CallingConvention.Cdecl)]
329    private static extern int igraph_matrix_transpose_x86([In, Out]igraph_matrix_t matrix);
330    [DllImport(X64Dll, EntryPoint = "igraph_matrix_transpose", CallingConvention = CallingConvention.Cdecl)]
331    private static extern int igraph_matrix_transpose_x64([In, Out]igraph_matrix_t matrix);
332    [DllImport(X86Dll, EntryPoint = "igraph_matrix_scale", CallingConvention = CallingConvention.Cdecl)]
333    private static extern int igraph_matrix_scale_x86([In, Out]igraph_matrix_t matrix, double by);
334    [DllImport(X64Dll, EntryPoint = "igraph_matrix_scale", CallingConvention = CallingConvention.Cdecl)]
335    private static extern int igraph_matrix_scale_x64([In, Out]igraph_matrix_t matrix, double by);
336    #endregion
337    #endregion
338
339    #region igraph_layout
340    internal static int igraph_layout_fruchterman_reingold(igraph_t graph, igraph_matrix_t res, bool use_seed, int niter, double start_temp, igraph_layout_grid_t grid, igraph_vector_t weights, igraph_vector_t minx, igraph_vector_t maxx, igraph_vector_t miny, igraph_vector_t maxy) {
341      return X86 ? igraph_layout_fruchterman_reingold_x86(graph, res, use_seed, niter, start_temp, grid, weights, minx, maxx, miny, maxy) : igraph_layout_fruchterman_reingold_x64(graph, res, use_seed, niter, start_temp, grid, weights, minx, maxx, miny, maxy);
342    }
343    internal static int igraph_layout_kamada_kawai(igraph_t graph, igraph_matrix_t res, bool use_seed, int maxiter, double epsilon, double kkconst, igraph_vector_t weights, igraph_vector_t minx, igraph_vector_t maxx, igraph_vector_t miny, igraph_vector_t maxy) {
344      return X86 ? igraph_layout_kamada_kawai_x86(graph, res, use_seed, maxiter, epsilon, kkconst, weights, minx, maxx, miny, maxy) : igraph_layout_kamada_kawai_x64(graph, res, use_seed, maxiter, epsilon, kkconst, weights, minx, maxx, miny, maxy);
345    }
346    internal static int igraph_layout_davidson_harel(igraph_t graph, igraph_matrix_t res, bool use_seed, int maxiter, int fineiter, double cool_fact, double weight_node_dist, double weight_border, double weight_edge_lengths, double weight_edge_crossings, double weight_node_edge_dist) {
347      return X86 ? igraph_layout_davidson_harel_x86(graph, res, use_seed, maxiter, fineiter, cool_fact, weight_node_dist, weight_border, weight_edge_lengths, weight_edge_crossings, weight_node_edge_dist) : igraph_layout_davidson_harel_x64(graph, res, use_seed, maxiter, fineiter, cool_fact, weight_node_dist, weight_border, weight_edge_lengths, weight_edge_crossings, weight_node_edge_dist);
348    }
349    internal static int igraph_layout_mds(igraph_t graph, igraph_matrix_t res, igraph_matrix_t dist = null, int dim = 2) {
350      var arpackoptions = GetDefaultArpackOptions();
351      var options = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(igraph_arpack_options_t)));
352      Marshal.StructureToPtr(arpackoptions, options, false);
353      try {
354        return X86 ? igraph_layout_mds_x86(graph, res, dist, dim, options) : igraph_layout_mds_x64(graph, res, dist, dim, options);
355      } finally {
356        Marshal.DestroyStructure(options, typeof(igraph_arpack_options_t));
357        Marshal.FreeHGlobal(options);
358      }
359    }
360
361    #region Platform specific DLL imports
362    [DllImport(X86Dll, EntryPoint = "igraph_layout_fruchterman_reingold", CallingConvention = CallingConvention.Cdecl)]
363    private static extern int igraph_layout_fruchterman_reingold_x86(igraph_t graph, [In, Out]igraph_matrix_t res, bool use_seed, int niter, double start_temp, igraph_layout_grid_t grid, igraph_vector_t weights, igraph_vector_t minx, igraph_vector_t maxx, igraph_vector_t miny, igraph_vector_t maxy);
364    [DllImport(X64Dll, EntryPoint = "igraph_layout_fruchterman_reingold", CallingConvention = CallingConvention.Cdecl)]
365    private static extern int igraph_layout_fruchterman_reingold_x64(igraph_t graph, [In, Out]igraph_matrix_t res, bool use_seed, int niter, double start_temp, igraph_layout_grid_t grid, igraph_vector_t weights, igraph_vector_t minx, igraph_vector_t maxx, igraph_vector_t miny, igraph_vector_t maxy);
366    [DllImport(X86Dll, EntryPoint = "igraph_layout_kamada_kawai", CallingConvention = CallingConvention.Cdecl)]
367    private static extern int igraph_layout_kamada_kawai_x86(igraph_t graph, [In, Out]igraph_matrix_t res, bool use_seed, int maxiter, double epsilon, double kkconst, igraph_vector_t weights, igraph_vector_t minx, igraph_vector_t maxx, igraph_vector_t miny, igraph_vector_t maxy);
368    [DllImport(X64Dll, EntryPoint = "igraph_layout_kamada_kawai", CallingConvention = CallingConvention.Cdecl)]
369    private static extern int igraph_layout_kamada_kawai_x64(igraph_t graph, [In, Out]igraph_matrix_t res, bool use_seed, int maxiter, double epsilon, double kkconst, igraph_vector_t weights, igraph_vector_t minx, igraph_vector_t maxx, igraph_vector_t miny, igraph_vector_t maxy);
370    [DllImport(X86Dll, EntryPoint = "igraph_layout_davidson_harel", CallingConvention = CallingConvention.Cdecl)]
371    private static extern int igraph_layout_davidson_harel_x86(igraph_t graph, [In, Out]igraph_matrix_t res, bool use_seed, int maxiter, int fineiter, double cool_fact, double weight_node_dist, double weight_border, double weight_edge_lengths, double weight_edge_crossings, double weight_node_edge_dist);
372    [DllImport(X64Dll, EntryPoint = "igraph_layout_davidson_harel", CallingConvention = CallingConvention.Cdecl)]
373    private static extern int igraph_layout_davidson_harel_x64(igraph_t graph, [In, Out]igraph_matrix_t res, bool use_seed, int maxiter, int fineiter, double cool_fact, double weight_node_dist, double weight_border, double weight_edge_lengths, double weight_edge_crossings, double weight_node_edge_dist);
374    [DllImport(X86Dll, EntryPoint = "igraph_layout_mds", CallingConvention = CallingConvention.Cdecl)]
375    private static extern int igraph_layout_mds_x86(igraph_t graph, [In, Out]igraph_matrix_t res, igraph_matrix_t dist, int dim, IntPtr options);
376    [DllImport(X64Dll, EntryPoint = "igraph_layout_mds", CallingConvention = CallingConvention.Cdecl)]
377    private static extern int igraph_layout_mds_x64(igraph_t graph, [In, Out]igraph_matrix_t res, igraph_matrix_t dist, int dim, IntPtr options);
378    #endregion
379    #endregion
380
381    #region igraph_iterators
382    internal static int igraph_vs_all(ref igraph_vs_t vs) {
383      return X86 ? igraph_vs_all_x86(ref vs) : igraph_vs_all_x64(ref vs);
384    }
385    internal static void igraph_vs_destroy(ref igraph_vs_t vs) {
386      if (X86) igraph_vs_destroy_x86(ref vs);
387      else igraph_vs_destroy_x64(ref vs);
388    }
389
390    #region Platform specific DLL imports
391    [DllImport(X86Dll, EntryPoint = "igraph_vs_all", CallingConvention = CallingConvention.Cdecl)]
392    private static extern int igraph_vs_all_x86([In, Out]ref igraph_vs_t vs);
393    [DllImport(X64Dll, EntryPoint = "igraph_vs_all", CallingConvention = CallingConvention.Cdecl)]
394    private static extern int igraph_vs_all_x64([In, Out]ref igraph_vs_t vs);
395    [DllImport(X86Dll, EntryPoint = "igraph_vs_destroy", CallingConvention = CallingConvention.Cdecl)]
396    private static extern void igraph_vs_destroy_x86([In, Out]ref igraph_vs_t vs);
397    [DllImport(X64Dll, EntryPoint = "igraph_vs_destroy", CallingConvention = CallingConvention.Cdecl)]
398    private static extern void igraph_vs_destroy_x64([In, Out]ref igraph_vs_t vs);
399    #endregion
400    #endregion
401  }
402}
Note: See TracBrowser for help on using the repository browser.