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 |
|
---|
22 | using System;
|
---|
23 | using System.Runtime.InteropServices;
|
---|
24 |
|
---|
25 | namespace 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 X64 = false;
|
---|
30 |
|
---|
31 | static DllImporter() {
|
---|
32 | X64 = 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 (X64) igraph_empty_x64(graph, n, directed);
|
---|
39 | else igraph_empty_x86(graph, n, directed);
|
---|
40 | }
|
---|
41 | internal static int igraph_destroy(igraph_t graph) {
|
---|
42 | return X64 ? igraph_destroy_x64(graph) : igraph_destroy_x86(graph);
|
---|
43 | }
|
---|
44 | #endregion
|
---|
45 |
|
---|
46 | #region igraph query
|
---|
47 | internal static int igraph_vcount(igraph_t graph) {
|
---|
48 | return X64 ? igraph_vcount_x64(graph) : igraph_vcount_x86(graph);
|
---|
49 | }
|
---|
50 | #endregion
|
---|
51 |
|
---|
52 | #region igraph manipulation
|
---|
53 | internal static int igraph_add_edge(igraph_t graph, int from, int to) {
|
---|
54 | return X64 ? igraph_add_edge_x64(graph, from, to) : igraph_add_edge_x86(graph, from, to);
|
---|
55 | }
|
---|
56 | #endregion
|
---|
57 |
|
---|
58 | #region Platform specific DLL imports
|
---|
59 | [DllImport(X86Dll, EntryPoint = "igraph_empty", CallingConvention = CallingConvention.Cdecl)]
|
---|
60 | private static extern void igraph_empty_x86([In, Out]igraph_t graph, int n, bool directed);
|
---|
61 | [DllImport(X64Dll, EntryPoint = "igraph_empty", CallingConvention = CallingConvention.Cdecl)]
|
---|
62 | private static extern void igraph_empty_x64([In, Out]igraph_t graph, int n, bool directed);
|
---|
63 | [DllImport(X86Dll, EntryPoint = "igraph_destroy", CallingConvention = CallingConvention.Cdecl)]
|
---|
64 | private static extern int igraph_destroy_x86([In, Out]igraph_t graph);
|
---|
65 | [DllImport(X64Dll, EntryPoint = "igraph_destroy", CallingConvention = CallingConvention.Cdecl)]
|
---|
66 | private static extern int igraph_destroy_x64([In, Out]igraph_t graph);
|
---|
67 | [DllImport(X86Dll, EntryPoint = "igraph_vcount", CallingConvention = CallingConvention.Cdecl)]
|
---|
68 | private static extern int igraph_vcount_x86(igraph_t graph);
|
---|
69 | [DllImport(X64Dll, EntryPoint = "igraph_vcount", CallingConvention = CallingConvention.Cdecl)]
|
---|
70 | private static extern int igraph_vcount_x64(igraph_t graph);
|
---|
71 | [DllImport(X86Dll, EntryPoint = "igraph_add_edge", CallingConvention = CallingConvention.Cdecl)]
|
---|
72 | private static extern int igraph_add_edge_x86([In, Out]igraph_t graph, int from, int to);
|
---|
73 | [DllImport(X64Dll, EntryPoint = "igraph_add_edge", CallingConvention = CallingConvention.Cdecl)]
|
---|
74 | private static extern int igraph_add_edge_x64([In, Out]igraph_t graph, int from, int to);
|
---|
75 | #endregion
|
---|
76 | #endregion
|
---|
77 |
|
---|
78 | #region igraph_rng
|
---|
79 | internal static int igraph_rng_get_integer(int l, int h) {
|
---|
80 | return X64 ? igraph_rng_get_integer_x64(igraph_rng_default_x64(), l, h) : igraph_rng_get_integer_x86(igraph_rng_default_x86(), l, h);
|
---|
81 | }
|
---|
82 | internal static int igraph_rng_seed(uint seed) {
|
---|
83 | return X64 ? igraph_rng_seed_x64(igraph_rng_default_x64(), seed) : igraph_rng_seed_x86(igraph_rng_default_x86(), seed);
|
---|
84 | }
|
---|
85 |
|
---|
86 | #region Platform specific DLL imports
|
---|
87 | [DllImport(X86Dll, EntryPoint = "igraph_rng_default", CallingConvention = CallingConvention.Cdecl)]
|
---|
88 | private static extern IntPtr igraph_rng_default_x86();
|
---|
89 | [DllImport(X64Dll, EntryPoint = "igraph_rng_default", CallingConvention = CallingConvention.Cdecl)]
|
---|
90 | private static extern IntPtr igraph_rng_default_x64();
|
---|
91 | [DllImport(X86Dll, EntryPoint = "igraph_rng_get_integer", CallingConvention = CallingConvention.Cdecl)]
|
---|
92 | private static extern int igraph_rng_get_integer_x86(IntPtr rng, int l, int h);
|
---|
93 | [DllImport(X64Dll, EntryPoint = "igraph_rng_get_integer", CallingConvention = CallingConvention.Cdecl)]
|
---|
94 | private static extern int igraph_rng_get_integer_x64(IntPtr rng, int l, int h);
|
---|
95 | [DllImport(X86Dll, EntryPoint = "igraph_rng_seed", CallingConvention = CallingConvention.Cdecl)]
|
---|
96 | private static extern int igraph_rng_seed_x86(IntPtr rng, uint seed);
|
---|
97 | [DllImport(X64Dll, EntryPoint = "igraph_rng_seed", CallingConvention = CallingConvention.Cdecl)]
|
---|
98 | private static extern int igraph_rng_seed_x64(IntPtr rng, uint seed);
|
---|
99 | #endregion
|
---|
100 | #endregion
|
---|
101 |
|
---|
102 | #region igraph_matrix
|
---|
103 | internal static int igraph_matrix_init(igraph_matrix_t matrix, int nrows, int ncols) {
|
---|
104 | return X64 ? igraph_matrix_init_x64(matrix, nrows, ncols) : igraph_matrix_init_x86(matrix, nrows, ncols);
|
---|
105 | }
|
---|
106 | internal static void igraph_matrix_destroy(igraph_matrix_t matrix) {
|
---|
107 | if (X64) igraph_matrix_destroy_x64(matrix);
|
---|
108 | else igraph_matrix_destroy_x86(matrix);
|
---|
109 | }
|
---|
110 |
|
---|
111 | internal static double igraph_matrix_e(igraph_matrix_t matrix, int row, int col) {
|
---|
112 | return X64 ? igraph_matrix_e_x64(matrix, row, col) : igraph_matrix_e_x86(matrix, row, col);
|
---|
113 | }
|
---|
114 |
|
---|
115 | internal static void igraph_matrix_set(igraph_matrix_t matrix, int row, int col, double value) {
|
---|
116 | if (X64) igraph_matrix_set_x64(matrix, row, col, value);
|
---|
117 | else igraph_matrix_set_x86(matrix, row, col, value);
|
---|
118 | }
|
---|
119 |
|
---|
120 | #region Platform specific DLL imports
|
---|
121 | [DllImport(X86Dll, EntryPoint = "igraph_matrix_init", CallingConvention = CallingConvention.Cdecl)]
|
---|
122 | private static extern int igraph_matrix_init_x86([In, Out]igraph_matrix_t matrix, int nrow, int ncol);
|
---|
123 | [DllImport(X64Dll, EntryPoint = "igraph_matrix_init", CallingConvention = CallingConvention.Cdecl)]
|
---|
124 | private static extern int igraph_matrix_init_x64([In, Out]igraph_matrix_t matrix, int nrow, int ncol);
|
---|
125 | [DllImport(X86Dll, EntryPoint = "igraph_matrix_destroy", CallingConvention = CallingConvention.Cdecl)]
|
---|
126 | private static extern void igraph_matrix_destroy_x86([In, Out]igraph_matrix_t matrix);
|
---|
127 | [DllImport(X64Dll, EntryPoint = "igraph_matrix_destroy", CallingConvention = CallingConvention.Cdecl)]
|
---|
128 | private static extern void igraph_matrix_destroy_x64([In, Out]igraph_matrix_t matrix);
|
---|
129 | [DllImport(X86Dll, EntryPoint = "igraph_matrix_e", CallingConvention = CallingConvention.Cdecl)]
|
---|
130 | private static extern double igraph_matrix_e_x86(igraph_matrix_t matrix, int row, int col);
|
---|
131 | [DllImport(X64Dll, EntryPoint = "igraph_matrix_e", CallingConvention = CallingConvention.Cdecl)]
|
---|
132 | private static extern double igraph_matrix_e_x64(igraph_matrix_t matrix, int row, int col);
|
---|
133 | [DllImport(X86Dll, EntryPoint = "igraph_matrix_set", CallingConvention = CallingConvention.Cdecl)]
|
---|
134 | private static extern double igraph_matrix_set_x86(igraph_matrix_t matrix, int row, int col, double value);
|
---|
135 | [DllImport(X64Dll, EntryPoint = "igraph_matrix_set", CallingConvention = CallingConvention.Cdecl)]
|
---|
136 | private static extern double igraph_matrix_set_x64(igraph_matrix_t matrix, int row, int col, double value);
|
---|
137 | #endregion
|
---|
138 | #endregion
|
---|
139 |
|
---|
140 | #region igraph_layout
|
---|
141 | 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) {
|
---|
142 | return X64 ? igraph_layout_fruchterman_reingold_x64(graph, res, use_seed, niter, start_temp, grid, weights, minx, maxx, miny, maxy) : igraph_layout_fruchterman_reingold_x86(graph, res, use_seed, niter, start_temp, grid, weights, minx, maxx, miny, maxy);
|
---|
143 | }
|
---|
144 |
|
---|
145 | #region Platform specific DLL imports
|
---|
146 | [DllImport(X86Dll, EntryPoint = "igraph_layout_fruchterman_reingold", CallingConvention = CallingConvention.Cdecl)]
|
---|
147 | 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);
|
---|
148 | [DllImport(X64Dll, EntryPoint = "igraph_layout_fruchterman_reingold", CallingConvention = CallingConvention.Cdecl)]
|
---|
149 | 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);
|
---|
150 | #endregion
|
---|
151 | #endregion
|
---|
152 |
|
---|
153 | }
|
---|
154 | }
|
---|