Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 11,12d10
- < #pragma region Floyd-Warshall
- <
- 27c25,28
- < int min_value(int a, int b)
- ---
- > /*
- > * Returns whether or not a weight is valid
- > */
- > bool valid_weight(int weight)
- 29,32c30,48
- < if (a == INFINITY)
- < return b;
- < if (b == INFINITY)
- < return a;
- ---
- > // Pre-conditions:
- > assert(true);
- > // Post-conditions: the function returned whether or not the weight was
- > // valid
- >
- > return weight >= 0 || weight == INFINITY;
- > }
- >
- > /*
- > * Returns the minimum weight of two weights
- > */
- > int min_weight(int a, int b)
- > {
- > // Pre-conditions:
- > assert(valid_weight(a) && valid_weight(b));
- > // Post-conditions: the minimum weight has been returned
- >
- > if (a == INFINITY || b == INFINITY)
- > return INFINITY;
- 59a76,80
- > // Pre-conditions:
- > assert(true);
- > // Post-conditions: the path has been initialized with INFINITY for all
- > // edges
- >
- 144a166,168
- > /*
- > * Adds two weights
- > */
- 146a171,174
- > // Pre-conditions:
- > assert(valid_weight(a) && valid_weight(b));
- > // Post-conditions: the sum of the weights was returned
- >
- 152c180,183
- < void distance2(Graph graph, Path path, int n)
- ---
- > /*
- > * Determines the shortest paths in a graph using iterative Floyd-Warshall
- > */
- > void distance(Graph graph, Path path, int n)
- 153a185,192
- > // Pre-conditions:
- > assert(n >= 0);
- > // Post-conditions: graph was filled with all shortest distances from the
- > // first node to the second and path was filled with the node that should
- > // be visited first if you want to go from one node to another, with
- > // INFINITY meaning the shortest way of going from the first node to the
- > // other is going directly from the first node to the other
- >
- 158c197
- < int new_weight = min_value(graph[i][j],
- ---
- > int new_weight = min_weight(graph[i][j],
- 170,173d208
- < #pragma endregion
- <
- < #pragma region Charles
- <
- 234c269
- <
- ---
- >
- 242c277
- < distance2(graph, path, NODE_COUNT - 1);
- ---
- > distance(graph, path, NODE_COUNT - 1);
- 288,289d322
- <
- < #pragma endregion
Add Comment
Please, Sign In to add comment