@@ -13,23 +13,44 @@ def setup_module(module):
1313
1414def test_connected_components ():
1515 for str_expr , str_expected in [
16- ("PlanarGraphQ[Graph[{}]]" , "False" ),
17- ("g = Graph[{1 -> 2, 2 -> 3, 3 <-> 4}];" , "Null" ),
18- ("SortList[ConnectedComponents[g]]" , "{{1}, {2}, {3, 4}}" ),
19- ("g = Graph[{1 -> 2, 2 -> 3, 3 -> 1}];" , "Null" ),
20- ("SortList[ConnectedComponents[g]]" , "{{1, 2, 3}}" ),
16+ ("PlanarGraphQ[Graph[{}]]" , "False" ),
17+ ("g = Graph[{1 -> 2, 2 -> 3, 3 <-> 4}];" , "Null" ),
18+ ("SortList[ConnectedComponents[g]]" , "{{1}, {2}, {3, 4}}" ),
19+ ("g = Graph[{1 -> 2, 2 -> 3, 3 -> 1}];" , "Null" ),
20+ ("SortList[ConnectedComponents[g]]" , "{{1, 2, 3}}" ),
2121 ]:
2222 check_evaluation (str_expr , str_expected )
2323
2424
2525def test_graph_distance ():
26- for str_expr , str_expected in [
27- ("GraphDistance[{1 <-> 2, 2 <-> 3, 3 <-> 4, 2 <-> 4, 4 -> 5}, 1, 5]" , "3" ),
28- ("GraphDistance[{1 <-> 2, 2 <-> 3, 3 <-> 4, 4 -> 2, 4 -> 5}, 1, 5]" , "4" ),
26+ for str_expr , str_expected , mess in [
27+ (
28+ "GraphDistance[{1 <-> 2, 2 <-> 3, 3 <-> 4, 2 <-> 4, 4 -> 5}, 1, 5]" ,
29+ "3" ,
30+ None ,
31+ ),
32+ ("GraphDistance[{1 <-> 2, 2 <-> 3, 3 <-> 4, 4 -> 2, 4 -> 5}, 1, 5]" , "4" , None ),
2933 # ("GraphDistance[{1 <-> 2, 2 <-> 3, 4 -> 3, 4 -> 2, 4 -> 5}, 1, 5]", "Infinity"),
3034 (
3135 "Sort[GraphDistance[{1 <-> 2, 2 <-> 3, 3 <-> 4, 2 <-> 4, 4 -> 5}, 3]]" ,
3236 "{0, 1, 1, 2, 2}" ,
37+ None ,
38+ ),
39+ (
40+ "GraphDistance[{}, 1, 1]" ,
41+ "GraphDistance[{}, 1, 1]" ,
42+ [
43+ "The vertex at position 2 in GraphDistance[{}, 1, 1] does not belong to "
44+ "the graph at position 1."
45+ ],
46+ ),
47+ (
48+ "GraphDistance[{1 -> 2}, 3, 4]" ,
49+ "GraphDistance[{1 -> 2}, 3, 4]" ,
50+ [
51+ "The vertex at position 2 in GraphDistance[{1 -> 2}, 3, 4] does not belong "
52+ "to the graph at position 1."
53+ ],
3354 ),
3455 ]:
35- check_evaluation (str_expr , str_expected )
56+ check_evaluation (str_expr , str_expected , expected_messages = mess )
0 commit comments