@@ -29,13 +29,15 @@ class GraphUtilsTest(absltest.TestCase):
2929
3030 def testAddEdge (self ):
3131 graph = {}
32- graph_utils .add_edge (graph , ['A' , 'B' , '0.5' ])
33- graph_utils .add_edge (graph , ['A' , 'C' , 0.7 ]) # Tests that the edge
34- graph_utils .add_edge (graph , ['A' , 'C' , 0.9 ]) # ...with maximal weight
35- graph_utils .add_edge (graph , ['A' , 'C' , 0.8 ]) # ...is used.
36- graph_utils .add_edge (graph , ('B' , 'A' , '0.4' ))
37- graph_utils .add_edge (graph , ('B' , 'C' )) # Tests default weight
38- graph_utils .add_edge (graph , ('D' , 'A' , 0.75 ))
32+ self .assertTrue (graph_utils .add_edge (graph , ['A' , 'B' , '0.5' ]))
33+ # The next 3 calls test that the edge with maximal weight is used.
34+ self .assertTrue (graph_utils .add_edge (graph , ['A' , 'C' , 0.7 ]))
35+ self .assertFalse (graph_utils .add_edge (graph , ['A' , 'C' , 0.9 ]))
36+ self .assertFalse (graph_utils .add_edge (graph , ['A' , 'C' , 0.8 ]))
37+ self .assertTrue (graph_utils .add_edge (graph , ('B' , 'A' , '0.4' )))
38+ # Tests that when no weight is specified, it defaults to 1.0.
39+ self .assertTrue (graph_utils .add_edge (graph , ('B' , 'C' )))
40+ self .assertTrue (graph_utils .add_edge (graph , ('D' , 'A' , 0.75 )))
3941 self .assertDictEqual (graph , GRAPH )
4042
4143 def testAddUndirectedEdges (self ):
0 commit comments