added a sanity check to verify graph has non zero nodes and edges