30 double cos_critical,
int check_edges_with_same_endpoint,
31 char *xsplines1,
char *xsplines2){
38 int iter1 = 0, iter2 = 0;
44 LIST(
double) x1 = {0};
45 LIST(
double) x2 = {0};
55 if(strstr(xsplines1,
"e,")){
57 xsplines1 = strstr(xsplines1,
"e,") + 2;
58 }
else if (strstr(xsplines1,
"s,")){
59 xsplines1 = strstr(xsplines1,
"s,") + 2;
62 for (
double x, y; xsplines1 && sscanf(xsplines1,
"%lf,%lf", &x, &y) == 2; ) {
63 if (endp1 && iter1 == 0){
71 xsplines1 = strchr(xsplines1,
' ');
72 if (!xsplines1)
break;
87 if(strstr(xsplines2,
"e,")){
89 xsplines2 = strstr(xsplines2,
"e,") + 2;
90 }
else if (strstr(xsplines2,
"s,")){
91 xsplines2 = strstr(xsplines2,
"s,") + 2;
94 for (
double x, y; xsplines2 && sscanf(xsplines2,
"%lf,%lf", &x, &y) == 2; ) {
95 if (endp2 && iter2 == 0){
103 xsplines2 = strchr(xsplines2,
' ');
104 if (!xsplines2)
break;
113 for (
size_t i = 0; i <
LIST_SIZE(&x1) / 2 - 1; i++) {
115 for (
size_t j = 0; j <
LIST_SIZE(&x2) / 2 - 1; j++) {
120 if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
121 if (cos_a > cos_critical) {
136 Agraph_t *g,
double angle,
double accuracy,
137 int check_edges_with_same_endpoint,
int seed) {
141 int *irn, *jcn, nz2 = 0;
142 double cos_critical = cos(angle/180*3.14159), cos_a;
143 int u1, v1, u2, v2, j;
144 double *colors =
NULL;
146 char **xsplines =
NULL;
151 fprintf(stderr,
"The gv file contains no or improper 2D coordinates\n");
156 irn =
A->ia; jcn =
A->ja;
157 const size_t nz =
A->nz;
160 for (
size_t i = 0; i < nz; i++){
161 if (irn[i] != jcn[i]){
168 fprintf(stderr,
"cos = %f, nz2 = %d\n", cos_critical, nz2);
174 clock_t start = clock();
178 for (
int i = 0; i < nz2; i++){
179 for (j = i+1; j < nz2; j++){
181 check_edges_with_same_endpoint, xsplines[i],
188 fprintf(stderr,
"cpu for dual graph =%10.3f", ((
double) (clock() - start))/CLOCKS_PER_SEC);
194 clock_t start = clock();
198 for (
int i = 0; i < nz2; i++){
199 u1 = irn[i]; v1 = jcn[i];
200 for (j = i+1; j < nz2; j++){
201 u2 = irn[j]; v2 = jcn[j];
203 if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
204 if (cos_a > cos_critical) {
210 fprintf(stderr,
"cpu for dual graph (splines) =%10.3f\n", ((
double) (clock() - start))/CLOCKS_PER_SEC);
218 clock_t start = clock();
220 const bool weightedQ =
false;
222 accuracy,
seed, &cdim, &colors);
225 fprintf(stderr,
"cpu for color assignment =%10.3f\n", ((
double) (clock() - start))/CLOCKS_PER_SEC);
231 " edges\n",
C->m,
C->nz);
241 for (
int i = 0; i < ne; i++){
SparseMatrix SparseMatrix_import_dot(Agraph_t *g, double **x, int format)
void attach_edge_colors(Agraph_t *g, size_t dim, double *colors)
int Import_dot_splines(Agraph_t *g, int *ne, char ***xsplines)
SparseMatrix SparseMatrix_new(size_t m, int n, size_t nz, int type, int format)
SparseMatrix SparseMatrix_from_coordinate_format(SparseMatrix A)
void SparseMatrix_delete(SparseMatrix A)
#define SparseMatrix_coordinate_form_add_entry(A, irn, jcn, val)
wrap SparseMatrix_coordinate_form_add_entry_ for type safety
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,...)
int node_distinct_coloring(const char *color_scheme, int *lightness, bool weightedQ, SparseMatrix A0, double accuracy, int seed, size_t *cdim0, double **colors)