def test_get_unvisited_neighbor__none_available(): start_v = Vertex('1') end_v = Vertex('2') start_v.connect(end_vertex=end_v) end_v.visited = True assert start_v.get_unvisited_neighbor() is None
def test_has_neighbor(): start_v = Vertex('1') assert start_v.has_neighbor() is False # Add a neighbor start_v.connect(end_vertex=Vertex('2')) assert start_v.has_neighbor()
def test_get_unvisited_neighbor__valid_result(): start_v = Vertex('1') end_v = Vertex('2') start_v.connect(end_vertex=end_v) result = start_v.get_unvisited_neighbor() assert result == end_v
def test_connect__dupe_edge_returns_False(): start_v = Vertex('1') end_v = Vertex('2') start_v.connect(end_vertex=end_v, edge_weight=5) # Add edge result = start_v.connect(end_vertex=end_v, edge_weight=5) # Add again assert result is False
def test_connect__same_vertices__no_edge_added(): start_v = Vertex('1') start_v.connect(end_vertex=start_v, edge_weight=5) assert len(start_v.edgelist) == 0
def test_connect__same_vertices_returns_False(): start_v = Vertex('1') assert start_v.connect(end_vertex=start_v, edge_weight=5) is False
def test_connect__edge_vertext(): start_v = Vertex('1') end_v = Vertex('2') start_v.connect(end_vertex=end_v, edge_weight=5) edge = start_v.edgelist[0] assert edge.vertex == end_v
def connected_vertex(): start_v = Vertex('1') end_v = Vertex('2') start_v.connect(end_vertex=end_v, edge_weight=5) # Add edge return start_v
def test_connect__creates_Edge_in_edgelist(): start_v = Vertex('1') end_v = Vertex('2') start_v.connect(end_vertex=end_v, edge_weight=5) assert len(start_v.edgelist) == 1
def test_connect__default_weight_is_0(): start_v = Vertex('1') end_v = Vertex('2') start_v.connect(end_vertex=end_v) assert start_v.edgelist[0].weight == 0
def test_connect__success_returns_True(): start_v = Vertex('1') end_v = Vertex('2') assert start_v.connect(end_vertex=end_v, edge_weight=5)