Even better in this case would be to check if the graph is directed using G.is_directed().