bfs c implementation with graph representation as sparse array