return color;
}
-#if 0
-static void posStr(char *buf, int dim, real * x, double sc)
-{
- if (dim == 3) {
- sprintf(buf, "%f,%f,%f", sc * x[0], sc * x[1], sc * x[2]);
- } else {
- sprintf(buf, "%f,%f", sc * x[0], sc * x[1]);
- }
-}
-
-static void attach_embedding(Agraph_t * g, int dim, double sc, real * x)
-{
- Agsym_t *sym = agattr(g, AGNODE, "pos", 0);
- Agnode_t *n;
- char buf[BUFS];
- int i = 0;
-
- if (!sym)
- sym = agattr(g, AGNODE, "pos", "");
-
- for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- assert(i == ND_id(n));
- posStr(buf, dim, x + i * dim, sc);
- agxset(n, sym, buf);
- i++;
- }
-
-}
-
-/* SparseMatrix_import_dot:
- * Assumes g is connected and simple, i.e., we can have a->b and b->a
- * but not a->b and a->b
- */
-SparseMatrix
-SparseMatrix_import_dot(Agraph_t * g, int dim, real ** label_sizes,
- real ** x, int format)
-{
- SparseMatrix A = 0;
- Agnode_t *n;
- Agedge_t *e;
- Agsym_t *sym;
- int nnodes;
- int nedges;
- int i, row;
- int *I;
- int *J;
- real *val;
- real v;
- int type = MATRIX_TYPE_REAL;
- real padding = 10;
-
- if (!g)
- return NULL;
- nnodes = agnnodes(g);
- nedges = agnedges(g);
- if (format != FORMAT_CSR) {
- fprintf(stderr, "Format %d not supported\n", format);
- exit(1);
- }
-
- /* Assign node ids */
- i = 0;
- for (n = agfstnode(g); n; n = agnxtnode(g, n))
- ND_id(n) = i++;
-
- I = N_NEW(nedges, int);
- J = N_NEW(nedges, int);
- val = N_NEW(nedges, real);
-
- sym = agndattr(g->proto->e, "wt");
- i = 0;
- for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- row = ND_id(n);
- for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
- I[i] = row;
- J[i] = ND_id(e->head);
- if (sym) {
- if (sscanf(agxget(e, sym->index), "%lf", &v) != 1)
- v = 1;
- } else
- v = 1;
- val[i] = v;
- i++;
- }
- }
-
- *label_sizes = N_NEW(2 * nnodes, real);
- for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- real sz;
- i = ND_id(n);
- if (agget(n, "width") && agget(n, "height")) {
- sscanf(agget(n, "width"), "%lf", &sz);
- /* (*label_sizes)[i*2] = POINTS(sz)*.6; */
- (*label_sizes)[i * 2] = POINTS(sz) * .5 + padding * 0.5;
- sscanf(agget(n, "height"), "%lf", &sz);
- /*(*label_sizes)[i*2+1] = POINTS(sz)*.6; */
- (*label_sizes)[i * 2 + 1] = POINTS(sz) * .5 + padding * 0.5;
- } else {
- (*label_sizes)[i * 2] = 4 * POINTS(0.75) * .5;
- (*label_sizes)[i * 2 + 1] = 4 * POINTS(0.5) * .5;
- }
- }
-
- if (x) {
- *x = N_NEW(dim * nnodes, real);
- for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
- real xx, yy;
- i = ND_id(n);
- if (agget(n, "pos")) {
- sscanf(agget(n, "pos"), "%lf,%lf", &xx, &yy);
- (*x)[i * dim] = xx;
- (*x)[i * dim + 1] = yy;
- } else {
- (*x)[i * dim] = 0;
- (*x)[i * dim + 1] = 0;
- }
- }
- }
-
- A = SparseMatrix_from_coordinate_arrays(nedges, nnodes, nnodes, I, J,
- val, type);
-
- FREE(I);
- FREE(J);
- FREE(val);
-
- return A;
-}
-#endif
-
static Agraph_t *makeDotGraph(SparseMatrix A, char *name, int dim,
real * x, int with_color, int with_label, int with_val)
{