spring_electrical.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #pragma once
  11. #include <sparse/SparseMatrix.h>
  12. #include <stdbool.h>
  13. enum {ERROR_NOT_SQUARE_MATRIX = -100};
  14. /* a flag to indicate that p should be set auto */
  15. #define AUTOP -1.0001234
  16. enum {SMOOTHING_NONE, SMOOTHING_STRESS_MAJORIZATION_GRAPH_DIST, SMOOTHING_STRESS_MAJORIZATION_AVG_DIST, SMOOTHING_STRESS_MAJORIZATION_POWER_DIST, SMOOTHING_SPRING, SMOOTHING_TRIANGLE, SMOOTHING_RNG};
  17. enum {QUAD_TREE_HYBRID_SIZE = 10000};
  18. enum {QUAD_TREE_NONE = 0, QUAD_TREE_NORMAL, QUAD_TREE_FAST, QUAD_TREE_HYBRID};
  19. struct spring_electrical_control_struct {
  20. double p;/*a negativve real number default to -1. repulsive force = dist^p */
  21. double K;/* the natural distance. If K < 0, K will be set to the average distance of an edge */
  22. int multilevels;/* if <=1, single level */
  23. int max_qtree_level;/* max level of quadtree */
  24. int maxiter;
  25. double step;/* initial step size */
  26. int random_seed;
  27. bool random_start : 1; ///< whether to apply SE from a random layout, or from exisiting layout
  28. bool adaptive_cooling : 1;
  29. bool beautify_leaves : 1;
  30. int smoothing;
  31. int overlap;
  32. bool do_shrinking;
  33. int tscheme; /* octree scheme. 0 (no octree), 1 (normal), 2 (fast) */
  34. double initial_scaling;/* how to scale the layout of the graph before passing to overlap removal algorithm.
  35. positive values are absolute in points, negative values are relative
  36. to average label size.
  37. */
  38. double rotation;/* degree of rotation */
  39. int edge_labeling_scheme; /* specifying whether to treat node of the form |edgelabel|* as a special node representing an edge label.
  40. 0 (no action, default), 1 (penalty based method to make that kind of node close to the center of its neighbor),
  41. 1 (penalty based method to make that kind of node close to the old center of its neighbor),
  42. 3 (two step process of overlap removal and straightening) */
  43. };
  44. typedef struct spring_electrical_control_struct *spring_electrical_control;
  45. spring_electrical_control spring_electrical_control_new(void);
  46. void spring_electrical_control_print(spring_electrical_control ctrl);
  47. void spring_electrical_embedding(int dim, SparseMatrix A0, spring_electrical_control ctrl, double *x, int *flag);
  48. void spring_electrical_embedding_fast(int dim, SparseMatrix A0, spring_electrical_control ctrl, double *x, int *flag);
  49. void multilevel_spring_electrical_embedding(int dim, SparseMatrix A0,
  50. spring_electrical_control ctrl,
  51. double *label_sizes, double *x,
  52. int n_edge_label_nodes,
  53. int *edge_label_nodes, int *flag);
  54. void spring_electrical_control_delete(spring_electrical_control ctrl);
  55. double average_edge_length(SparseMatrix A, int dim, double *coord);
  56. void spring_electrical_spring_embedding(int dim, SparseMatrix A, SparseMatrix D, spring_electrical_control ctrl, double *x, int *flag);
  57. void pcp_rotate(int n, int dim, double *x);