SLIDE 50 Ling-Chieh Kung (NTU IM) Programming Design – Complexity and Graphs 50 / 54
Implementation: main function
int main() { int nodeCnt = 5; bool adjacent[MAX_NODE_CNT][MAX_NODE_CNT] = {{1, 1, 0, 0, 1}, {1, 1, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 1, 1}, {1, 0, 0, 1, 1}}; int dist[MAX_NODE_CNT] = {0}; int source = 0; distFromSource(adjacent, dist, nodeCnt, source); cout << "\nThe complete result: \n"; for(int i = 0; i < nodeCnt; i++) cout << dist[i] << " "; return 0; }
Complexity The “big O” notation Terminology of graphs Graph algorithms