Updated graph if-check for Spark