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