/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/neatogen/bfs.h

Go to the documentation of this file.
00001 /* $Id: bfs.h,v 1.3 2006/12/07 22:49:36 erg Exp $ $Revision: 1.3 $ */
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 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 #ifndef _BFS_H_
00022 #define _BFS_H_
00023 
00024 #include "defs.h"
00025 
00026 #ifdef __cplusplus
00027     class Queue {
00028       private:
00029         int *data;
00030         int queueSize;
00031         int end;
00032         int start;
00033       public:
00034          Queue(int size) {
00035             data = new int[size];
00036              queueSize = size;
00037              start = 0;
00038              end = 0;
00039         } ~Queue() {
00040             delete[]data;
00041         } void initQueue(int startVertex) {
00042             data[0] = startVertex;
00043             start = 0;
00044             end = 1;
00045         }
00046 
00047         bool dequeue(int &vertex) {
00048 
00049             if (start >= end)
00050                 return false;   /* underflow */
00051 
00052             vertex = data[start++];
00053             return true;
00054 
00055         }
00056 
00057         bool enqueue(int vertex) {
00058             if (end >= queueSize)
00059                 return false;   /* overflow */
00060             data[end++] = vertex;
00061             return true;
00062         }
00063     };
00064 
00065 
00066     void bfs(int vertex, vtx_data * graph, int n, DistType * dist,
00067              Queue & Q);
00068     void bfs_bounded(int vertex, vtx_data * graph, int n, DistType * dist,
00069                      Queue & Q, int bound, int *visited_nodes,
00070                      int &num_visited_nodes);
00071 #else
00072     typedef struct {
00073         int *data;
00074         int queueSize;
00075         int end;
00076         int start;
00077     } Queue;
00078 
00079     extern void mkQueue(Queue *, int);
00080     extern void freeQueue(Queue *);
00081     extern void initQueue(Queue *, int startVertex);
00082     extern boolean deQueue(Queue *, int *);
00083     extern boolean enQueue(Queue *, int);
00084 
00085     extern void bfs(int, vtx_data *, int, DistType *, Queue *);
00086     extern int bfs_bounded(int, vtx_data *, int, DistType *, Queue *, int,
00087                            int *);
00088 #endif
00089 
00090 #endif
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif

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