All pastes #253962 Raw Edit

Miscellany

public cpp v1 · immutable
#253962 ·published 2006-11-21 09:26 UTC
rendered paste body
BFS...#define INFINITY 999struct city{	City connectedTo[MAX_CONNECTIONS];	int numConnections;	int value;	int level;}BFSHelper ( Graph graph, int level){	//basically go through and increment 	//cities next to us	int i = 0;	for(i = 0; i < NUM_CITIES; i++){		if graph->city[i]->level == level){			//check out all cities next to it and increment visited			int j;			City curCity = graph->cities[i];			for (j = 0; j < MAX_CONNECTIONS && j < curCity->numConnections; j++){				if (curCity->connections[j]->level > level + 1){					curCity->connections[j]->level = level + 1;				}			}		}	}	}BFS (Graph graph, int from, int find) {	ResetVisited(graph); //sets level = 999;	int curLevel = 1;	graph->cities[from]->level = 0;	while(graph->cities[find]->level == INFINITY){		BFSHelper(graph, curLevel);		curLevel++;	}}