31 int closestVertex, neighbor;
35 for (i = 0; i < n; i++)
41 if (graph[0].ewgts ==
NULL) {
42 while (
deQueue(Q, &closestVertex)) {
43 closestDist = dist[closestVertex];
44 for (i = 1; i < graph[closestVertex].
nedges; i++) {
45 neighbor = graph[closestVertex].
edges[i];
46 if (dist[neighbor] < -0.5) {
47 dist[neighbor] = closestDist + 1;
53 while (
deQueue(Q, &closestVertex)) {
54 closestDist = dist[closestVertex];
55 for (i = 1; i < graph[closestVertex].
nedges; i++) {
56 neighbor = graph[closestVertex].
edges[i];
57 if (dist[neighbor] < -0.5) {
60 (
DistType) graph[closestVertex].ewgts[i];
68 for (i = 0; i < n; i++)
70 dist[i] = closestDist + 10;
75 Queue * Q,
int bound,
int *visited_nodes)
83 int closestVertex, neighbor;
94 while (
deQueue(Q, &closestVertex)) {
95 closestDist = dist[closestVertex];
96 if (closestDist > bound) {
97 dist[closestVertex] = -1;
100 visited_nodes[num_visit++] = closestVertex;
102 for (i = 1; i < graph[closestVertex].
nedges; i++) {
103 neighbor = graph[closestVertex].
edges[i];
104 if (dist[neighbor] < -0.5) {
105 dist[neighbor] = closestDist + 1;
113 while (
deQueue(Q, &closestVertex)) {
114 dist[closestVertex] = -1;
149 qp->
data[0] = startVertex;
Queue * newQueue(int size)
void bfs(int vertex, vtx_data *graph, int n, DistType *dist, Queue *Q)
void freeQueue(Queue *qp)
boolean enQueue(Queue *qp, int vertex)
int bfs_bounded(int vertex, vtx_data *graph, int n, DistType *dist, Queue *Q, int bound, int *visited_nodes)
void initQueue(Queue *qp, int startVertex)
void mkQueue(Queue *qp, int size)
Agraph_t * graph(char *name)
double dist(Site *s, Site *t)
boolean deQueue(Queue *qp, int *vertex)