| 1 |
/************************************************************************* |
| 2 |
* Copyright (c) 2011 AT&T Intellectual Property |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* https://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: Details at https://graphviz.org |
| 9 |
*************************************************************************/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include <sparse/SparseMatrix.h> |
| 14 |
#include <stdbool.h> |
| 15 |
|
| 16 |
enum {ERROR_NOT_SQUARE_MATRIX = -100}; |
| 17 |
|
| 18 |
/* a flag to indicate that p should be set auto */ |
| 19 |
#define AUTOP -1.0001234 |
| 20 |
|
| 21 |
enum {SMOOTHING_NONE, SMOOTHING_STRESS_MAJORIZATION_GRAPH_DIST, SMOOTHING_STRESS_MAJORIZATION_AVG_DIST, SMOOTHING_STRESS_MAJORIZATION_POWER_DIST, SMOOTHING_SPRING, SMOOTHING_TRIANGLE, SMOOTHING_RNG}; |
| 22 |
|
| 23 |
enum {QUAD_TREE_HYBRID_SIZE = 10000}; |
| 24 |
|
| 25 |
enum {QUAD_TREE_NONE = 0, QUAD_TREE_NORMAL, QUAD_TREE_FAST, QUAD_TREE_HYBRID}; |
| 26 |
|
| 27 |
typedef struct { |
| 28 |
double p; ///< a negative real number default to -1. repulsive force = distáµ– |
| 29 |
double K;/* the natural distance. If K < 0, K will be set to the average distance of an edge */ |
| 30 |
int multilevels;/* if <=1, single level */ |
| 31 |
int max_qtree_level;/* max level of quadtree */ |
| 32 |
int maxiter; |
| 33 |
double step;/* initial step size */ |
| 34 |
int random_seed; |
| 35 |
bool random_start : 1; ///< whether to apply SE from a random layout, or from existing layout |
| 36 |
bool adaptive_cooling : 1; |
| 37 |
bool beautify_leaves : 1; |
| 38 |
int smoothing; |
| 39 |
int overlap; |
| 40 |
bool do_shrinking; |
| 41 |
int tscheme; /* octree scheme. 0 (no octree), 1 (normal), 2 (fast) */ |
| 42 |
double initial_scaling;/* how to scale the layout of the graph before passing to overlap removal algorithm. |
| 43 |
positive values are absolute in points, negative values are relative |
| 44 |
to average label size. |
| 45 |
*/ |
| 46 |
double rotation;/* degree of rotation */ |
| 47 |
int edge_labeling_scheme; /* specifying whether to treat node of the form |edgelabel|* as a special node representing an edge label. |
| 48 |
0 (no action, default), 1 (penalty based method to make that kind of node close to the center of its neighbor), |
| 49 |
1 (penalty based method to make that kind of node close to the old center of its neighbor), |
| 50 |
3 (two step process of overlap removal and straightening) */ |
| 51 |
} spring_electrical_control; |
| 52 |
|
| 53 |
spring_electrical_control spring_electrical_control_new(void); |
| 54 |
void spring_electrical_control_print(spring_electrical_control ctrl); |
| 55 |
|
| 56 |
void spring_electrical_embedding(int dim, SparseMatrix A0, |
| 57 |
spring_electrical_control *ctrl, double *x, |
| 58 |
int *flag); |
| 59 |
void spring_electrical_embedding_fast(int dim, SparseMatrix A0, |
| 60 |
spring_electrical_control *ctrl, |
| 61 |
double *x, int *flag); |
| 62 |
|
| 63 |
void multilevel_spring_electrical_embedding(int dim, SparseMatrix A0, |
| 64 |
spring_electrical_control *ctrl, |
| 65 |
double *label_sizes, double *x, |
| 66 |
int n_edge_label_nodes, |
| 67 |
int *edge_label_nodes, int *flag); |
| 68 |
|
| 69 |
double average_edge_length(SparseMatrix A, int dim, double *coord); |
| 70 |
|
| 71 |
void spring_electrical_spring_embedding(int dim, SparseMatrix A, SparseMatrix D, |
| 72 |
spring_electrical_control *ctrl, |
| 73 |
double *x, int *flag); |
| 74 |
|
| 75 |
void pcp_rotate(int n, int dim, double *x); |