28 double cos_critical,
int check_edges_with_same_endpoint,
29 char *xsplines1,
char *xsplines2){
36 int iter1 = 0, iter2 = 0;
42 LIST(
double) x1 = {0};
43 LIST(
double) x2 = {0};
53 if(strstr(xsplines1,
"e,")){
55 xsplines1 = strstr(xsplines1,
"e,") + 2;
56 }
else if (strstr(xsplines1,
"s,")){
57 xsplines1 = strstr(xsplines1,
"s,") + 2;
60 for (
double x, y; xsplines1 && sscanf(xsplines1,
"%lf,%lf", &x, &y) == 2; ) {
61 if (endp1 && iter1 == 0){
69 xsplines1 = strchr(xsplines1,
' ');
70 if (!xsplines1)
break;
85 if(strstr(xsplines2,
"e,")){
87 xsplines2 = strstr(xsplines2,
"e,") + 2;
88 }
else if (strstr(xsplines2,
"s,")){
89 xsplines2 = strstr(xsplines2,
"s,") + 2;
92 for (
double x, y; xsplines2 && sscanf(xsplines2,
"%lf,%lf", &x, &y) == 2; ) {
93 if (endp2 && iter2 == 0){
101 xsplines2 = strchr(xsplines2,
' ');
102 if (!xsplines2)
break;
111 for (
size_t i = 0; i <
LIST_SIZE(&x1) / 2 - 1; i++) {
113 for (
size_t j = 0; j <
LIST_SIZE(&x2) / 2 - 1; j++) {
118 if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
119 if (cos_a > cos_critical) {
134 Agraph_t *g,
double angle,
double accuracy,
135 int check_edges_with_same_endpoint,
int seed) {
139 int *irn, *jcn, nz2 = 0;
140 double cos_critical = cos(angle/180*3.14159), cos_a;
141 int u1, v1, u2, v2, j;
142 double *colors =
NULL;
144 char **xsplines =
NULL;
149 fprintf(stderr,
"The gv file contains no or improper 2D coordinates\n");
154 irn =
A->ia; jcn =
A->ja;
155 const size_t nz =
A->nz;
158 for (
size_t i = 0; i < nz; i++){
159 if (irn[i] != jcn[i]){
166 fprintf(stderr,
"cos = %f, nz2 = %d\n", cos_critical, nz2);
172 clock_t start = clock();
176 for (
int i = 0; i < nz2; i++){
177 for (j = i+1; j < nz2; j++){
179 check_edges_with_same_endpoint, xsplines[i],
186 fprintf(stderr,
"cpu for dual graph =%10.3f", ((
double) (clock() - start))/CLOCKS_PER_SEC);
192 clock_t start = clock();
196 for (
int i = 0; i < nz2; i++){
197 u1 = irn[i]; v1 = jcn[i];
198 for (j = i+1; j < nz2; j++){
199 u2 = irn[j]; v2 = jcn[j];
201 if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
202 if (cos_a > cos_critical) {
208 fprintf(stderr,
"cpu for dual graph (splines) =%10.3f\n", ((
double) (clock() - start))/CLOCKS_PER_SEC);
216 clock_t start = clock();
218 const bool weightedQ =
false;
220 accuracy,
seed, &cdim, &colors);
223 fprintf(stderr,
"cpu for color assignment =%10.3f\n", ((
double) (clock() - start))/CLOCKS_PER_SEC);
228 fprintf(stderr,
"The edge conflict graph has %d nodes and %" PRISIZE_T
229 " edges\n",
C->m,
C->nz);
239 for (
int i = 0; i < ne; i++){
SparseMatrix SparseMatrix_import_dot(Agraph_t *g, int dim, double **x, int format)
void attach_edge_colors(Agraph_t *g, int dim, double *colors)
int Import_dot_splines(Agraph_t *g, int *ne, char ***xsplines)
SparseMatrix SparseMatrix_from_coordinate_format(SparseMatrix A)
SparseMatrix SparseMatrix_coordinate_form_add_entry(SparseMatrix A, int irn, int jcn, const void *val)
void SparseMatrix_delete(SparseMatrix A)
SparseMatrix SparseMatrix_new(int m, int n, size_t nz, int type, int format)
Agraph_t * edge_distinct_coloring(const char *color_scheme, int *lightness, Agraph_t *g, double angle, double accuracy, int check_edges_with_same_endpoint, int seed)
static int splines_intersect(size_t dim, double cos_critical, int check_edges_with_same_endpoint, char *xsplines1, char *xsplines2)
double intersection_angle(double *p1, double *p2, double *q1, double *q2)
type-generic dynamically expanding list
#define LIST_AT(list, index)
#define LIST_APPEND(list, item)
int node_distinct_coloring(const char *color_scheme, int *lightness, bool weightedQ, SparseMatrix A0, double accuracy, int seed, int *cdim0, double **colors)