def check_graph(G, is_planar=None): """Raises an exception if the lr_planarity check returns a wrong result Parameters ---------- G : NetworkX graph is_planar : bool The expected result of the planarity check. If set to None only counter example or embedding are verified. """ # obtain results of planarity check is_planar_lr, result = nx.check_planarity(G, True) is_planar_lr_rec, result_rec = check_planarity_recursive(G, True) if is_planar is not None: # set a message for the assert if is_planar: msg = "Wrong planarity check result. Should be planar." else: msg = "Wrong planarity check result. Should be non-planar." # check if the result is as expected assert is_planar == is_planar_lr, msg assert is_planar == is_planar_lr_rec, msg if is_planar_lr: # check embedding check_embedding(G, result) check_embedding(G, result_rec) else: # check counter example check_counterexample(G, result) check_counterexample(G, result_rec)
def check_graph(G, is_planar=None): """Raises an exception if the lr_planarity check returns a wrong result Parameters ---------- G : NetworkX graph is_planar : bool The expected result of the planarity check. If set to None only counter example or embedding are verified. """ # obtain results of planarity check is_planar_lr, result = nx.check_planarity(G, True) is_planar_lr_rec, result_rec = check_planarity_recursive(G, True) if is_planar is not None: # set a message for the assert if is_planar: msg = "Wrong planarity check result. Should be planar." else: msg = "Wrong planarity check result. Should be non-planar." # check if the result is as expected assert_equals(is_planar, is_planar_lr, msg) assert_equals(is_planar, is_planar_lr_rec, msg) if is_planar_lr: # check embedding check_embedding(G, result) check_embedding(G, result_rec) else: # check counter example check_counterexample(G, result) check_counterexample(G, result_rec)