Annotation of researchv10no/cmd/dag/emit_gd.c, revision 1.1

1.1     ! root        1: /* emit code like that of dave johnson's 'graphdraw' format.
        !             2:  * slightly incompatible but this format can easily by
        !             3:  * mangled for other purposes (UNIX TOOLS APPROACH)
        !             4:  * tabs used as delimiters; spaces can appear in node labels.
        !             5:  */
        !             6: 
        !             7: #include "draw_dag.h"
        !             8: #include "dag.h"
        !             9: #include "parsedag.h"
        !            10: 
        !            11: /* map tab to space */
        !            12: static char* escape(char *s) {
        !            13:        char *rv = s;
        !            14:        do {
        !            15:                if (*s == '\t') *s = ' ';
        !            16:        } while (*s++);
        !            17:        return rv;
        !            18: }
        !            19: 
        !            20: void emit_graphdraw() {
        !            21:        int *Degree = new int[N];
        !            22:        for (int n_edges = 0, i = 0; i < N; i++)
        !            23:                for (DAG_edge_t *e= Edge[i]; e; e = e->nextof()) {
        !            24:                        Degree[i]++;
        !            25:                        n_edges++;
        !            26:                }
        !            27:        printf("%d\t%d\td\n",N,n_edges);        // "d" for directed
        !            28:        for (i = 0; i < N; i++) {
        !            29:                char *printname;
        !            30:                if (Node[i]->label.type) printname = Node[i]->label.value;
        !            31:                else printname = Node[i]->name;
        !            32: 
        !            33:                printf("%d\t\"%s\"\t%d\t%d\tL\n",Degree[i],escape(printname),Node[i]->pos.x,Node[i]->pos.y);
        !            34:                for (e = Edge[i]; e; e = e->nextof()) {
        !            35:                        if (e->label.type)
        !            36:                                printf("%d\t\"%s\"\tL",e->node,escape(e->label.value));
        !            37:                        else
        !            38:                                printf("%d\tL",e->node);
        !            39:                        for (int nsp = 0; e->splinept[nsp].x >= 0; nsp++);
        !            40:                        printf("\t%d",nsp);
        !            41:                        for (int sp = 0; sp < nsp; sp++)
        !            42:                                printf("\t%d\t%d",e->splinept[sp].x,e->splinept[sp].y);
        !            43:                        printf("\n");
        !            44:                }
        !            45:        }
        !            46:        delete Degree;
        !            47: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.