25 double cos_critical,
int check_edges_with_same_endpoint,
26 char *xsplines1,
char *xsplines2){
33 int iter1 = 0, iter2 = 0;
39 LIST(
double) x1 = {0};
40 LIST(
double) x2 = {0};
50 if(strstr(xsplines1,
"e,")){
52 xsplines1 = strstr(xsplines1,
"e,") + 2;
53 }
else if (strstr(xsplines1,
"s,")){
54 xsplines1 = strstr(xsplines1,
"s,") + 2;
57 for (
double x, y; xsplines1 && sscanf(xsplines1,
"%lf,%lf", &x, &y) == 2; ) {
58 if (endp1 && iter1 == 0){
66 xsplines1 = strchr(xsplines1,
' ');
67 if (!xsplines1)
break;
82 if(strstr(xsplines2,
"e,")){
84 xsplines2 = strstr(xsplines2,
"e,") + 2;
85 }
else if (strstr(xsplines2,
"s,")){
86 xsplines2 = strstr(xsplines2,
"s,") + 2;
89 for (
double x, y; xsplines2 && sscanf(xsplines2,
"%lf,%lf", &x, &y) == 2; ) {
90 if (endp2 && iter2 == 0){
98 xsplines2 = strchr(xsplines2,
' ');
99 if (!xsplines2)
break;
108 for (
size_t i = 0; i <
LIST_SIZE(&x1) / 2 - 1; i++) {
110 for (
size_t j = 0; j <
LIST_SIZE(&x2) / 2 - 1; j++) {
115 if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
116 if (cos_a > cos_critical) {
131 Agraph_t *g,
double angle,
double accuracy,
132 int check_edges_with_same_endpoint,
int seed) {
136 int *irn, *jcn, nz, nz2 = 0;
137 double cos_critical = cos(angle/180*3.14159), cos_a;
138 int u1, v1, u2, v2, i, j;
139 double *colors =
NULL;
141 char **xsplines =
NULL;
146 fprintf(stderr,
"The gv file contains no or improper 2D coordinates\n");
151 irn =
A->ia; jcn =
A->ja;
155 for (i = 0; i < nz; i++){
156 if (irn[i] != jcn[i]){
163 fprintf(stderr,
"cos = %f, nz2 = %d\n", cos_critical, nz2);
169 clock_t start = clock();
173 for (i = 0; i < nz2; i++){
174 for (j = i+1; j < nz2; j++){
176 check_edges_with_same_endpoint, xsplines[i],
183 fprintf(stderr,
"cpu for dual graph =%10.3f", ((
double) (clock() - start))/CLOCKS_PER_SEC);
189 clock_t start = clock();
193 for (i = 0; i < nz2; i++){
194 u1 = irn[i]; v1 = jcn[i];
195 for (j = i+1; j < nz2; j++){
196 u2 = irn[j]; v2 = jcn[j];
198 if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
199 if (cos_a > cos_critical) {
205 fprintf(stderr,
"cpu for dual graph (splines) =%10.3f\n", ((
double) (clock() - start))/CLOCKS_PER_SEC);
213 clock_t start = clock();
215 const bool weightedQ =
false;
217 accuracy,
seed, &cdim, &colors);
220 fprintf(stderr,
"cpu for color assignment =%10.3f\n", ((
double) (clock() - start))/CLOCKS_PER_SEC);
225 fprintf(stderr,
"The edge conflict graph has %d nodes and %d edges\n",
C->m,
C->nz);
235 for (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, int 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)