hackerrank graphs

Can anyone find what is mistake in my solution to the problem roads and libraries.
I am getting a SIGSEGV error.

Roads and Libraries Discussions | Algorithms | HackerRank

I think, because you don’t read graph in the first branch case when lib < road.