Esempio n. 1
0
static void write_graph(Agraph_t * g, GVJ_t * job, int top, state_t* sp)
{
    Agnode_t* np; 
    Agedge_t* ep; 
    int ncnt = 0;
    int ecnt = 0;
    int sgcnt = 0;
    int has_subgs;
    Dt_t* map;

    if (top) {
	map = dtopen (&intDisc, Dtoset);
	aginit(g, AGNODE, ID, sizeof(gvid_t), FALSE);
	aginit(g, AGEDGE, ID, sizeof(gvid_t), FALSE);
	aginit(g, AGRAPH, ID, -((int)sizeof(gvid_t)), FALSE);
	sgcnt = label_subgs(g, sgcnt, map);
	for (np = agfstnode(g); np; np = agnxtnode(g,np)) {
	    if (IS_CLUSTER(np)) {
		ND_gid(np) = lookup(map, agnameof(np));
	    }
	    else {
		ND_gid(np) = sgcnt + ncnt++;
	    }
	    for (ep = agfstout(g, np); ep; ep = agnxtout(g,ep)) {
		ED_gid(ep) = ecnt++;
	    }
	}
	dtclose(map);
    }

    indent(job, sp->Level++);
    gvputs(job, "{\n");
    write_hdr(g, job, top, sp);
    write_attrs((Agobj_t*)g, job, sp);
    if (top) {
	gvputs(job, ",\n");
	indent(job, sp->Level);
	gvprintf(job, "\"_subgraph_cnt\": %d", sgcnt);
    } else {
	gvputs(job, ",\n");
	indent(job, sp->Level);
	gvprintf(job, "\"_gvid\": %d", GD_gid(g));
    }
    has_subgs = write_subgs(g, job, top, sp);
    write_nodes (g, job, top, has_subgs, sp);
    write_edges (g, job, top, sp);
    gvputs(job, "\n");
    sp->Level--;
    indent(job, sp->Level);
    if (top)
	gvputs(job, "}\n");
    else
	gvputs(job, "}");
}
Esempio n. 2
0
static void
write_edges(FILE *fp, const NSegment *tree)
{
   if (tree == NULL) return;

   const NSegment *left  = tree->left;
   const NSegment *right = tree->right;

   if (left)  {
      write_edges(fp, left);
      write_edge(fp, tree, left);
   }
   if (right) {
      write_edges(fp, right);
      write_edge(fp, tree, right);
   }
#if 0
   const NSegment *parent = tree->up;
   if (parent) {
      write_edge(fp, tree, parent);
   }
#endif
}
Esempio n. 3
0
/* write piecewise polynomial molecular surface to output file */
int write_surface (struct surface *srf, FILE *fp_surface)
{
	/* writing */
	write_header (srf, srf -> mol -> name, fp_surface); if (error()) return(0);
	write_varieties (srf, fp_surface); if (error()) return(0);
	write_vertices (srf, fp_surface); if (error()) return(0);
	write_circles (srf, fp_surface); if (error()) return(0);
	write_arcs (srf, fp_surface); if (error()) return(0);
	write_faces (srf, fp_surface); if (error()) return(0);
	write_cycles (srf, fp_surface); if (error()) return(0);
	write_edges (srf, fp_surface); if (error()) return(0);
	write_components (srf, fp_surface); if (error()) return(0);

	fclose (fp_surface);
	return (1);
}
Esempio n. 4
0
void
write_dot(const NSegment *node, const NSegment *subtree,
          const NSegment *inserted, const char *name)
{
   assert(node != NULL);
   assert(name != NULL);

   subtree_root = subtree;    // globalise
   inserted_node = inserted;  // globalise

   char file[strlen(name) + 10];
   sprintf(file, "%s.dot", name);    // construct file name
   FILE *fp = fopen(file, "w");
   assert(fp);

   fprintf(fp, "digraph \"%s\" {\n", name);
   fprintf(fp, "\n/* Nodes */\n\n");
   write_nodes(fp, node);
   fprintf(fp, "\n/* Edges */\n\n");
   write_edges(fp, node);
   fprintf(fp, "}\n");

   fclose(fp);
}