-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
BugUnexpected behavior or errorsUnexpected behavior or errors
Description
Operating System
Linux (Debian-based)
Package Manager
Not applicable
Bug Details:
My code included around 400 more nodes than the tests since I added any node that had negative depth to my graph regardless of whether or not it had valid neighbors. When I changed my code to include that condition, I passed. Since I assume you don't want to change the tests, I suggest adding a note that your tests expect that condition in one's graph construction logic.
Steps to Reproduce
` def _generate_graph(self):
"""
Generates the graph used for Tsunami time prediction.
Specifically, uses method of the Graph class to add edges
between grid points below sea level, weighted by the get_time() method.
Nodes are labeled by their zero-indexed location in grid.
"""
for row_index, row in enumerate(self.depths_grid):
for col_index, col in enumerate(row):
curr_depth = self.depths_grid[row_index][col_index]
if curr_depth < 0:
self.add_node((row_index, col_index))
self._add_weighted_edges_of_neighbors_to_graph(row_index, col_index, curr_depth)
def _add_weighted_edges_of_neighbors_to_graph(self, row, col, curr_depth):
"""
Given a node (row, col), add the edges between it and its neighbors to the graph.
"""
neighbors = self._get_neighbors((row, col))
for neighbor in neighbors:
neighbor_depth = self.depths_grid[neighbor[0]][neighbor[1]]
time = self._get_time(curr_depth, neighbor_depth)
self.add_edge((row, col), neighbor, time)`
Volume & Lab (By Name)
Volume 2: Dijkstra
Source Lines
Relevant segments in `/Volume2/Dijkstra/Dijkstra.md`:
- Approximate line: 489:
- Section: Problem 4:
- List item: _generate_graph(): adds nodes ...
Metadata
Metadata
Assignees
Labels
BugUnexpected behavior or errorsUnexpected behavior or errors