|
Graphviz
2.31.20130618.0446
|
00001 /* $Id$ $Revision$ */ 00002 /* vim:set shiftwidth=4 ts=8: */ 00003 00004 /************************************************************************* 00005 * Copyright (c) 2011 AT&T Intellectual Property 00006 * All rights reserved. This program and the accompanying materials 00007 * are made available under the terms of the Eclipse Public License v1.0 00008 * which accompanies this distribution, and is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * 00011 * Contributors: See CVS logs. Details at http://www.graphviz.org/ 00012 *************************************************************************/ 00013 00014 #ifdef __cplusplus 00015 extern "C" { 00016 #endif 00017 00018 #ifndef _BFS_H_ 00019 #define _BFS_H_ 00020 00021 #include "defs.h" 00022 00023 #ifdef __cplusplus 00024 class Queue { 00025 private: 00026 int *data; 00027 int queueSize; 00028 int end; 00029 int start; 00030 public: 00031 Queue(int size) { 00032 data = new int[size]; 00033 queueSize = size; 00034 start = 0; 00035 end = 0; 00036 } ~Queue() { 00037 delete[]data; 00038 } void initQueue(int startVertex) { 00039 data[0] = startVertex; 00040 start = 0; 00041 end = 1; 00042 } 00043 00044 bool dequeue(int &vertex) { 00045 00046 if (start >= end) 00047 return false; /* underflow */ 00048 00049 vertex = data[start++]; 00050 return true; 00051 00052 } 00053 00054 bool enqueue(int vertex) { 00055 if (end >= queueSize) 00056 return false; /* overflow */ 00057 data[end++] = vertex; 00058 return true; 00059 } 00060 }; 00061 00062 00063 void bfs(int vertex, vtx_data * graph, int n, DistType * dist, 00064 Queue & Q); 00065 void bfs_bounded(int vertex, vtx_data * graph, int n, DistType * dist, 00066 Queue & Q, int bound, int *visited_nodes, 00067 int &num_visited_nodes); 00068 #else 00069 typedef struct { 00070 int *data; 00071 int queueSize; 00072 int end; 00073 int start; 00074 } Queue; 00075 00076 extern void mkQueue(Queue *, int); 00077 extern void freeQueue(Queue *); 00078 extern void initQueue(Queue *, int startVertex); 00079 extern boolean deQueue(Queue *, int *); 00080 extern boolean enQueue(Queue *, int); 00081 00082 extern void bfs(int, vtx_data *, int, DistType *, Queue *); 00083 extern int bfs_bounded(int, vtx_data *, int, DistType *, Queue *, int, 00084 int *); 00085 #endif 00086 00087 #endif 00088 00089 #ifdef __cplusplus 00090 } 00091 #endif
1.7.5