check_graph function

Check input graph