File: igraph_layout.h

package info (click to toggle)
igraph 0.10.2%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 16,176 kB
  • sloc: ansic: 121,500; cpp: 21,699; xml: 2,734; python: 411; makefile: 147; javascript: 20; sh: 9
file content (293 lines) | stat: -rw-r--r-- 16,217 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/* -*- mode: C -*-  */
/*
   IGraph library.
   Copyright (C) 2009-2012  Gabor Csardi <csardi.gabor@gmail.com>
   334 Harvard street, Cambridge, MA 02139 USA

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, MA
   02110-1301 USA

*/

#ifndef IGRAPH_LAYOUT_H
#define IGRAPH_LAYOUT_H

#include "igraph_decls.h"

#include "igraph_constants.h"
#include "igraph_datatype.h"
#include "igraph_error.h"
#include "igraph_iterators.h"
#include "igraph_matrix_list.h"
#include "igraph_types.h"
#include "igraph_vector.h"
#include "igraph_vector_ptr.h"
#include "igraph_matrix.h"

__BEGIN_DECLS

/**
 * \section about_layouts
 *
 * <para>Layout generator functions (or at least most of them) try to place the
 * vertices and edges of a graph on a 2D plane or in 3D space in a way
 * which visually pleases the human eye.</para>
 *
 * <para>They take a graph object and a number of parameters as arguments
 * and return an \type igraph_matrix_t, in which each row gives the
 * coordinates of a vertex.</para>
 */

/* -------------------------------------------------- */
/* Layouts                                            */
/* -------------------------------------------------- */

IGRAPH_EXPORT igraph_error_t igraph_layout_random(const igraph_t *graph, igraph_matrix_t *res);
IGRAPH_EXPORT igraph_error_t igraph_layout_circle(const igraph_t *graph, igraph_matrix_t *res,
                                       igraph_vs_t order);
IGRAPH_EXPORT igraph_error_t igraph_layout_star(const igraph_t *graph, igraph_matrix_t *res,
                                     igraph_integer_t center, const igraph_vector_int_t *order);
IGRAPH_EXPORT igraph_error_t igraph_layout_grid(const igraph_t *graph, igraph_matrix_t *res, igraph_integer_t width);
IGRAPH_EXPORT igraph_error_t igraph_layout_fruchterman_reingold(const igraph_t *graph,
                                                     igraph_matrix_t *res,
                                                     igraph_bool_t use_seed,
                                                     igraph_integer_t niter,
                                                     igraph_real_t start_temp,
                                                     igraph_layout_grid_t grid,
                                                     const igraph_vector_t *weight,
                                                     const igraph_vector_t *minx,
                                                     const igraph_vector_t *maxx,
                                                     const igraph_vector_t *miny,
                                                     const igraph_vector_t *maxy);

IGRAPH_EXPORT igraph_error_t igraph_layout_kamada_kawai(const igraph_t *graph, igraph_matrix_t *res,
                                             igraph_bool_t use_seed, igraph_integer_t maxiter,
                                             igraph_real_t epsilon, igraph_real_t kkconst,
                                             const igraph_vector_t *weights,
                                             const igraph_vector_t *minx, const igraph_vector_t *maxx,
                                             const igraph_vector_t *miny, const igraph_vector_t *maxy);

IGRAPH_EXPORT igraph_error_t igraph_layout_lgl(const igraph_t *graph, igraph_matrix_t *res,
                                    igraph_integer_t maxiter, igraph_real_t maxdelta,
                                    igraph_real_t area, igraph_real_t coolexp,
                                    igraph_real_t repulserad, igraph_real_t cellsize, igraph_integer_t root);
IGRAPH_EXPORT igraph_error_t igraph_layout_reingold_tilford(const igraph_t *graph, igraph_matrix_t *res,
                                                 igraph_neimode_t mode,
                                                 const igraph_vector_int_t *roots,
                                                 const igraph_vector_int_t *rootlevel);
IGRAPH_EXPORT igraph_error_t igraph_layout_reingold_tilford_circular(const igraph_t *graph,
                                                          igraph_matrix_t *res,
                                                          igraph_neimode_t mode,
                                                          const igraph_vector_int_t *roots,
                                                          const igraph_vector_int_t *rootlevel);
IGRAPH_EXPORT igraph_error_t igraph_layout_sugiyama(const igraph_t *graph, igraph_matrix_t *res,
                                         igraph_t *extd_graph, igraph_vector_int_t *extd_to_orig_eids,
                                         const igraph_vector_int_t* layers, igraph_real_t hgap,
                                         igraph_real_t vgap, igraph_integer_t maxiter, const igraph_vector_t *weights);

IGRAPH_EXPORT igraph_error_t igraph_layout_random_3d(const igraph_t *graph, igraph_matrix_t *res);
IGRAPH_EXPORT igraph_error_t igraph_layout_sphere(const igraph_t *graph, igraph_matrix_t *res);
IGRAPH_EXPORT igraph_error_t igraph_layout_grid_3d(const igraph_t *graph, igraph_matrix_t *res,
                                        igraph_integer_t width, igraph_integer_t height);
IGRAPH_EXPORT igraph_error_t igraph_layout_fruchterman_reingold_3d(const igraph_t *graph,
                                                        igraph_matrix_t *res,
                                                        igraph_bool_t use_seed,
                                                        igraph_integer_t niter,
                                                        igraph_real_t start_temp,
                                                        const igraph_vector_t *weight,
                                                        const igraph_vector_t *minx,
                                                        const igraph_vector_t *maxx,
                                                        const igraph_vector_t *miny,
                                                        const igraph_vector_t *maxy,
                                                        const igraph_vector_t *minz,
                                                        const igraph_vector_t *maxz);

IGRAPH_EXPORT igraph_error_t igraph_layout_kamada_kawai_3d(const igraph_t *graph, igraph_matrix_t *res,
                                                igraph_bool_t use_seed, igraph_integer_t maxiter,
                                                igraph_real_t epsilon, igraph_real_t kkconst,
                                                const igraph_vector_t *weights,
                                                const igraph_vector_t *minx, const igraph_vector_t *maxx,
                                                const igraph_vector_t *miny, const igraph_vector_t *maxy,
                                                const igraph_vector_t *minz, const igraph_vector_t *maxz);

IGRAPH_EXPORT igraph_error_t igraph_layout_graphopt(const igraph_t *graph,
                                         igraph_matrix_t *res, igraph_integer_t niter,
                                         igraph_real_t node_charge, igraph_real_t node_mass,
                                         igraph_real_t spring_length,
                                         igraph_real_t spring_constant,
                                         igraph_real_t max_sa_movement,
                                         igraph_bool_t use_seed);

IGRAPH_EXPORT igraph_error_t igraph_layout_mds(const igraph_t *graph, igraph_matrix_t *res,
                                    const igraph_matrix_t *dist, igraph_integer_t dim);

IGRAPH_EXPORT igraph_error_t igraph_layout_bipartite(const igraph_t *graph,
                                          const igraph_vector_bool_t *types,
                                          igraph_matrix_t *res, igraph_real_t hgap,
                                          igraph_real_t vgap, igraph_integer_t maxiter);

IGRAPH_EXPORT igraph_error_t igraph_layout_umap(const igraph_t *graph,
                                                igraph_matrix_t *res,
                                                igraph_bool_t use_seed,
                                                const igraph_vector_t *distances,
                                                igraph_real_t min_dist,
                                                igraph_integer_t epochs,
                                                igraph_real_t sampling_prob);

IGRAPH_EXPORT igraph_error_t igraph_layout_umap_3d(const igraph_t *graph,
                                                igraph_matrix_t *res,
                                                igraph_bool_t use_seed,
                                                const igraph_vector_t *distances,
                                                igraph_real_t min_dist,
                                                igraph_integer_t epochs,
                                                igraph_real_t sampling_prob);

/**
 * \struct igraph_layout_drl_options_t
 * Parameters for the DrL layout generator
 *
 * \member edge_cut The edge cutting parameter.
 *    Edge cutting is done in the late stages of the
 *    algorithm in order to achieve less dense layouts.  Edges are cut
 *    if there is a lot of stress on them (a large value in the
 *    objective function sum).  The edge cutting parameter is a value
 *    between 0 and 1 with 0 representing no edge cutting and 1
 *    representing maximal edge cutting. The default value is 32/40.
 * \member init_iterations Number of iterations, initial phase.
 * \member init_temperature Start temperature, initial phase.
 * \member init_attraction Attraction, initial phase.
 * \member init_damping_mult Damping factor, initial phase.
 * \member liquid_iterations Number of iterations in the liquid phase.
 * \member liquid_temperature Start temperature in the liquid phase.
 * \member liquid_attraction Attraction in the liquid phase.
 * \member liquid_damping_mult Multiplicatie damping factor, liquid phase.
 * \member expansion_iterations Number of iterations in the expansion phase.
 * \member expansion_temperature Start temperature in the expansion phase.
 * \member expansion_attraction Attraction, expansion phase.
 * \member expansion_damping_mult Damping factor, expansion phase.
 * \member cooldown_iterations Number of iterations in the cooldown phase.
 * \member cooldown_temperature Start temperature in the cooldown phase.
 * \member cooldown_attraction Attraction in the cooldown phase.
 * \member cooldown_damping_mult Damping fact int the cooldown phase.
 * \member crunch_iterations Number of iterations in the crunch phase.
 * \member crunch_temperature Start temperature in the crunch phase.
 * \member crunch_attraction Attraction in the crunch phase.
 * \member crunch_damping_mult Damping factor in the crunch phase.
 * \member simmer_iterations Number of iterations in the simmer phase.
 * \member simmer_temperature Start temperature in te simmer phase.
 * \member simmer_attraction Attraction in the simmer phase.
 * \member simmer_damping_mult Multiplicative damping factor in the simmer phase.
 */

typedef struct igraph_layout_drl_options_t {
    igraph_real_t    edge_cut;
    igraph_integer_t init_iterations;
    igraph_real_t    init_temperature;
    igraph_real_t    init_attraction;
    igraph_real_t    init_damping_mult;
    igraph_integer_t liquid_iterations;
    igraph_real_t    liquid_temperature;
    igraph_real_t    liquid_attraction;
    igraph_real_t    liquid_damping_mult;
    igraph_integer_t expansion_iterations;
    igraph_real_t    expansion_temperature;
    igraph_real_t    expansion_attraction;
    igraph_real_t    expansion_damping_mult;
    igraph_integer_t cooldown_iterations;
    igraph_real_t    cooldown_temperature;
    igraph_real_t    cooldown_attraction;
    igraph_real_t    cooldown_damping_mult;
    igraph_integer_t crunch_iterations;
    igraph_real_t    crunch_temperature;
    igraph_real_t    crunch_attraction;
    igraph_real_t    crunch_damping_mult;
    igraph_integer_t simmer_iterations;
    igraph_real_t    simmer_temperature;
    igraph_real_t    simmer_attraction;
    igraph_real_t    simmer_damping_mult;
} igraph_layout_drl_options_t;

/**
 * \typedef igraph_layout_drl_default_t
 * Predefined parameter templates for the DrL layout generator
 *
 * These constants can be used to initialize a set of DrL parameters.
 * These can then be modified according to the user's needs.
 * \enumval IGRAPH_LAYOUT_DRL_DEFAULT The deafult parameters.
 * \enumval IGRAPH_LAYOUT_DRL_COARSEN Slightly modified parameters to
 *      get a coarser layout.
 * \enumval IGRAPH_LAYOUT_DRL_COARSEST An even coarser layout.
 * \enumval IGRAPH_LAYOUT_DRL_REFINE Refine an already calculated layout.
 * \enumval IGRAPH_LAYOUT_DRL_FINAL Finalize an already refined layout.
 */

typedef enum { IGRAPH_LAYOUT_DRL_DEFAULT = 0,
               IGRAPH_LAYOUT_DRL_COARSEN,
               IGRAPH_LAYOUT_DRL_COARSEST,
               IGRAPH_LAYOUT_DRL_REFINE,
               IGRAPH_LAYOUT_DRL_FINAL
             } igraph_layout_drl_default_t;

IGRAPH_EXPORT igraph_error_t igraph_layout_drl_options_init(igraph_layout_drl_options_t *options,
                                                 igraph_layout_drl_default_t templ);
IGRAPH_EXPORT igraph_error_t igraph_layout_drl(const igraph_t *graph, igraph_matrix_t *res,
                                    igraph_bool_t use_seed,
                                    const igraph_layout_drl_options_t *options,
                                    const igraph_vector_t *weights);

IGRAPH_EXPORT igraph_error_t igraph_layout_drl_3d(const igraph_t *graph, igraph_matrix_t *res,
                                       igraph_bool_t use_seed,
                                       const igraph_layout_drl_options_t *options,
                                       const igraph_vector_t *weights);

IGRAPH_EXPORT igraph_error_t igraph_layout_merge_dla(const igraph_vector_ptr_t *graphs,
                                          const igraph_matrix_list_t *coords,
                                          igraph_matrix_t *res);

IGRAPH_EXPORT igraph_error_t igraph_layout_gem(const igraph_t *graph, igraph_matrix_t *res,
                                    igraph_bool_t use_seed, igraph_integer_t maxiter,
                                    igraph_real_t temp_max, igraph_real_t temp_min,
                                    igraph_real_t temp_init);

IGRAPH_EXPORT igraph_error_t igraph_layout_davidson_harel(const igraph_t *graph, igraph_matrix_t *res,
                                               igraph_bool_t use_seed, igraph_integer_t maxiter,
                                               igraph_integer_t fineiter, igraph_real_t cool_fact,
                                               igraph_real_t weight_node_dist, igraph_real_t weight_border,
                                               igraph_real_t weight_edge_lengths,
                                               igraph_real_t weight_edge_crossings,
                                               igraph_real_t weight_node_edge_dist);

/**
 * \typedef igraph_root_choice_t
 * \brief Root choice heuristic for tree visualizations.
 *
 * Used with \ref igraph_roots_for_tree_layout().
 */

typedef enum {
    IGRAPH_ROOT_CHOICE_DEGREE,
    IGRAPH_ROOT_CHOICE_ECCENTRICITY
} igraph_root_choice_t;

IGRAPH_EXPORT igraph_error_t igraph_roots_for_tree_layout(
        const igraph_t *graph,
        igraph_neimode_t mode,
        igraph_vector_int_t *roots,
        igraph_root_choice_t use_eccentricity);


__END_DECLS

#endif