Clariant Interview Question

How to solve a problem related to graphs