Final Challenge #2
Lesson 9 of 9 in Coddy's Breadth-First Search - Graph Algorithms course.
Challenge
MediumOne more challenge.
Write a function named distances that takes n, the flat edges array (undirected), and a start vertex, and returns an array where position v is the shortest distance (in edges) from start to vertex v. Use -1 for vertices that cannot be reached.
For example, with edges [0,1, 0,2, 1,3, 2,3] from start 0 the distances are [0, 1, 1, 2].
Try it yourself
#include <stdlib.h>
int* distances(int n, int* edges, int edges_size, int start, int* returnSize) {
// Write code here
*returnSize = 0;
return edges;
}