hierarchy.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <neatogen/sparsegraph.h>
  12. #include <stddef.h>
  13. typedef struct {
  14. int nedges; // degree, including self-loop
  15. int *edges; // neighbors; edges[0] = self
  16. int size; // no. of original nodes contained
  17. int active_level; // Node displayed iff active_level == node's level
  18. int globalIndex; // Each node has a unique ID over all levels
  19. // position of node in universal coordinate system
  20. float x_coord;
  21. float y_coord;
  22. // position of node in physical (device) coordinate system
  23. float physical_x_coord;
  24. float physical_y_coord;
  25. //previous coords and active level (for animation)
  26. float old_physical_x_coord;
  27. float old_physical_y_coord;
  28. int old_active_level;
  29. } ex_vtx_data;
  30. typedef struct {
  31. int nlevels;
  32. v_data ** graphs;
  33. ex_vtx_data ** geom_graphs;
  34. int * nvtxs;
  35. int * nedges;
  36. /* Node i on level k is mapped to coarse node v2cv[k][i] on level k+1
  37. */
  38. int ** v2cv;
  39. /* Coarse node i on level k contains nodes cv2v[k][2*i] and
  40. * cv2v[k][2*i+1] on level k-1. If it contains only 1 node, then
  41. * cv2v[k][2*i+1] will be -1
  42. */
  43. int ** cv2v;
  44. int maxNodeIndex;
  45. } Hierarchy;
  46. typedef struct {
  47. int num_fine_nodes; /* 50 */
  48. double coarsening_rate; /* 2.5 */
  49. } levelparms_t;
  50. typedef struct {
  51. // if dist2_limit true, don't contract nodes of distance larger than 2
  52. // if false then also distance 3 is possible
  53. int dist2_limit; /* TRUE */
  54. } hierparms_t;
  55. Hierarchy* create_hierarchy(v_data * graph, int nvtxs, int nedges,
  56. ex_vtx_data* geom_graph, int ngeom_edges, hierparms_t*);
  57. void set_active_levels(Hierarchy*, int*, int, levelparms_t*);
  58. double find_closest_active_node(Hierarchy*, double x, double y, int*);
  59. size_t extract_active_logical_coords(Hierarchy *hierarchy, int node, int level,
  60. double *x_coords, double *y_coords, size_t counter);
  61. int set_active_physical_coords(Hierarchy *, int node, int level,
  62. double *x_coords, double *y_coords, int counter);
  63. void init_active_level(Hierarchy* hierarchy, int level);
  64. // creating a geometric graph:
  65. int init_ex_graph(v_data * graph1, v_data * graph2, int n,
  66. double *x_coords, double *y_coords, ex_vtx_data ** gp);
  67. // layout distortion:
  68. void rescale_layout_polar(double * x_coords, double * y_coords,
  69. double * x_foci, double * y_foci, int num_foci, size_t n, int interval,
  70. double width, double height, double distortion);
  71. void find_physical_coords(Hierarchy*, int, int, double *x, double *y);
  72. void find_old_physical_coords(Hierarchy * hierarchy, int level, int node, double *x,double *y);
  73. int find_active_ancestor(Hierarchy*, int, int);
  74. void find_active_ancestor_info(Hierarchy * hierarchy, int level, int node, int *levell,int *nodee);
  75. void quicksort_place(double *place, int *ordering, size_t size);