/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/circogen/block.c

Go to the documentation of this file.
00001 /* $Id: block.c,v 1.1.1.1 2004/12/23 04:04:28 ellson Exp $ $Revision: 1.1.1.1 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 
00018 #include <circular.h>
00019 #include        <block.h>
00020 #include        <assert.h>
00021 
00022 void initBlocklist(blocklist_t * bl)
00023 {
00024     bl->first = NULL;
00025     bl->last = NULL;
00026 }
00027 
00028 /*
00029 void
00030 cleanBlocklist(blocklist_t* sp)
00031 {
00032         block_t*  bp;
00033         block_t*  temp;
00034 
00035     if (!sp) return;
00036         for(bp = sp->first; bp; bp = temp) {
00037                 temp = bp->next;
00038                 freeBlock(bp);
00039         }
00040 }
00041 */
00042 
00043 block_t *mkBlock(Agraph_t * g)
00044 {
00045     block_t *sn;
00046 
00047     sn = NEW(block_t);
00048     initBlocklist(&sn->children);
00049     sn->sub_graph = g;
00050     return sn;
00051 }
00052 
00053 void freeBlock(block_t * sp)
00054 {
00055     if (!sp)
00056         return;
00057     freeNodelist(sp->circle_list);
00058     free(sp);
00059 }
00060 
00061 /* appendBlock:
00062  * add block at end
00063  */
00064 void appendBlock(blocklist_t * bl, block_t * bp)
00065 {
00066     bp->next = NULL;
00067     if (bl->last) {
00068         bl->last->next = bp;
00069         bl->last = bp;
00070     } else {
00071         bl->first = bp;
00072         bl->last = bp;
00073     }
00074 }
00075 
00076 /* insertBlock:
00077  * add block at beginning
00078  */
00079 void insertBlock(blocklist_t * bl, block_t * bp)
00080 {
00081     if (bl->first) {
00082         bp->next = bl->first;
00083         bl->first = bp;
00084     } else {
00085         bl->first = bp;
00086         bl->last = bp;
00087     }
00088 }
00089 
00090 #ifdef DEBUG
00091 void printBlocklist(blocklist_t * snl)
00092 {
00093     block_t *bp;
00094     for (bp = snl->first; bp; bp = bp->next) {
00095         Agnode_t *n;
00096         char *p;
00097         Agraph_t *g = bp->sub_graph;
00098         fprintf(stderr, "block=%s\n", g->name);
00099         for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
00100             Agedge_t *e;
00101             if (PARENT(n))
00102                 p = PARENT(n)->name;
00103             else
00104                 p = "<nil>";
00105             fprintf(stderr, "  %s (%d %s)\n", n->name, VAL(n), p);
00106             for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
00107                 fprintf(stderr, "    %s--%s\n", e->tail->name,
00108                         e->head->name);
00109             }
00110         }
00111     }
00112 }
00113 #endif

Generated on Mon Mar 31 19:03:23 2008 for Graphviz by  doxygen 1.5.1