check if graph is valid