Annotation of researchv10no/cmd/dag/draw_dag.h, revision 1.1

1.1     ! root        1: #include       <stdio.h>
        !             2: #include       <string.h>
        !             3: #include       <ctype.h>
        !             4: #include       <math.h>
        !             5: #include       <libc.h>
        !             6: #include       <memory.h>
        !             7: 
        !             8: #define                Maxint  (((unsigned) 1 << 31) - 1)
        !             9: 
        !            10: typedef int (*qsortcmpfun)(void*,void*);
        !            11: #ifndef QSORTDCL
        !            12: #ifdef MICC
        !            13: extern "C" {
        !            14:        extern void qsort(char*,int, int, qsortcmpfun);
        !            15: }
        !            16: #else
        !            17:        extern void qsort(char*,int, int, qsortcmpfun);
        !            18: #endif  MICC
        !            19: #endif QSORTDCL
        !            20: 
        !            21: struct Point {
        !            22:        int     x;
        !            23:        int     y;
        !            24: };
        !            25: 
        !            26: // edge structure for input graphs
        !            27: struct edge_t {
        !            28:        int     node;           // head or tail node
        !            29:        int     weight;         // cost of stretching this edge
        !            30:        int     width;          // the width of the edge.  0 = invis.
        !            31:        int     minlen;         // minimum length of the edge
        !            32:        union {
        !            33:        int     count;          // # of multiple edges in a class
        !            34:                                // 'count' is used in our Outedges and Inedges
        !            35:        int     place;          // where it should be placed in its class
        !            36:                                // of multiple edges
        !            37:        };
        !            38:        union {
        !            39:                Point   *splinept;      // spline control pts (last is (-1,-1))
        !            40:                edge_t  *chain;         // chaining of broken edges
        !            41:        };
        !            42:        edge_t  *link;          // to link inedges and outedges
        !            43:        edge_t  *next;
        !            44:        Point   top;            // points from which the end-points can be
        !            45:        Point   bottom;         // stretched to intersect weird node shapes
        !            46: 
        !            47:        edge_t(int innode, edge_t *innext)      // for boring linked lists
        !            48:        {
        !            49:                node = innode;
        !            50:                next = innext;
        !            51:        }
        !            52:        edge_t(int innode, int inweight, int inwidth, int inminlen, edge_t* innext) {
        !            53:                node    = innode;
        !            54:                weight  = inweight;
        !            55:                width   = inwidth;
        !            56:                minlen  = inminlen;
        !            57:                next    = innext;
        !            58:                count   = 1;
        !            59:        }
        !            60:        edge_t() {      
        !            61:                /* this establishes the defaults for edges */
        !            62:                node    = -1;
        !            63:                weight  = 1;
        !            64:                width   = 1;
        !            65:                minlen  = 1;
        !            66:                count   = 1;
        !            67:                /* others are zero by operator new */
        !            68:        }
        !            69: };
        !            70: 
        !            71: struct node_t {
        !            72:        char*   name;
        !            73:        Point   pos;
        !            74:        int             width;          // across the rank
        !            75:        int             height;         // above&below the rank
        !            76: };
        !            77: 
        !            78: struct options_t {
        !            79:        int     quick;          // optimize for speed not drawing quality.
        !            80:        int     verbose;        // say lots of things.
        !            81:        int     rankadjust;     // 0 = uneven OK, 1 = all equal, 2 = exact 
        !            82:        int     ranksep;        // default separation between adjacent ranks
        !            83:        int     nodesep;        // minimum separation between adjacent nodes
        !            84:        int xbound;             // if "fill" x limit of drawing area else 0
        !            85:        int ybound;             // if "fill" y limit of drawing area else 0
        !            86: 
        !            87:        int     **same_nodes,n_same_nodes;
        !            88:        int     *source_nodes;
        !            89:        int     *sink_nodes;
        !            90: };
        !            91: 
        !            92: overload max;
        !            93: static inline double max(double a, double b) { return a > b ? a : b; }
        !            94: static inline int max(int a, int b) { return a > b ? a : b; }
        !            95: 
        !            96: overload min;
        !            97: static inline double min(double a, double b) { return a < b ? a : b; }
        !            98: static inline int min(int a, int b) { return a < b ? a : b; }
        !            99: 
        !           100: static inline void swap(int& a, int& b) { int t; t = a; a = b; b = t;}
        !           101: 
        !           102: static inline int iabs(int a) { return a < 0 ? -a : a; }
        !           103: 
        !           104: extern void    draw_dag(int,node_t**,edge_t**,options_t);
        !           105: extern void    dag_start(int,node_t**,edge_t**,options_t);
        !           106: extern void    dag_delstem();
        !           107: extern void    dag_insstem();
        !           108: extern void    dag_levels(int,int,int);
        !           109: extern void    dag_positions(int,int);
        !           110: extern void    dag_ranks();
        !           111: extern void    dag_unitedges();
        !           112: extern void    dag_end(node_t**,edge_t**);
        !           113: extern void    dag_simplex(int,int,long**,long*,long*,int,int*);
        !           114: extern void    dag_spline();
        !           115: extern void    deledges(int,edge_t**);
        !           116: extern int     longedge(int,int);
        !           117: extern void    panic(char*);
        !           118: 
        !           119: //     The following variables and storage space are available to users
        !           120: //     after a call to draw_dag(). In particular, Nodepos and Levelpos
        !           121: //     define the virtual locations assigned to nodes and levels.
        !           122: 
        !           123: extern int     N_real_nodes,   // actual number of input nodes
        !           124:                N_nodes,        // number of nodes at various phases
        !           125:                N_edges,        // total number of edges
        !           126:                N_self_edges,   // # of loops detected
        !           127:                N_flat_edges,   // # of edges whose ends are at the same level
        !           128:                N_repeat_edges, // # of multi-edges deleted
        !           129:                N_revert_edges; // # of edges whose direction is reverted
        !           130: extern edge_t  **Inedges,      // in-edges for each node
        !           131:                **Outedges,     // out-edges
        !           132:                **Noedges,      // self-edges and flat edges
        !           133:                **Istems,       // in stem-edges
        !           134:                **Ostems;       // out stem edges
        !           135: extern int     *Stems;         // stem nodes
        !           136: extern int     *Trueheight;    // save heights for when stem nodes are removed
        !           137: 
        !           138: extern int     *Root;          // union trees of vertices at same ranks
        !           139: 
        !           140: extern int     N_component;    // number of connected components
        !           141: extern int     *Component;     // connected component numbers of nodes
        !           142: 
        !           143: extern int     *Level,         // levels assigned to nodes
        !           144:                Maxlevel,       // maximum level assigned to any node
        !           145:                *N_level,       // number of nodes at each level
        !           146:                *Invert,        // indices of nodes in their ranks
        !           147:                **Rank,         // array of ordered lists of nodes
        !           148:                Levelsep,       // separation between levels
        !           149:                *Levelheight,   // thickness of layers
        !           150:                *Levelpos;      // position of levels
        !           151: 
        !           152: extern int     *Nodepos,       // node positions
        !           153:                *Deleted,       // virtual nodes that were deleted
        !           154:                *Width,         // widths of nodes
        !           155:                Nodesep,        // minimum separation between nodes
        !           156:                *Height;        // heights of nodes
        !           157: 
        !           158: extern int     Xbound,Ybound;  // if "fill" then size of box to fill, else 0
        !           159: 
        !           160: extern int     Verbose;        // say lots of things
        !           161: 

unix.superglobalmegacorp.com

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