-
Notifications
You must be signed in to change notification settings - Fork 5
/
shortest_path.hpp
58 lines (50 loc) · 1.74 KB
/
shortest_path.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* @file shortest_path.cpp
* Implimentation file for using our templated Graph to determine shortest paths.
*/
#include <vector>
#include <fstream>
#include "CME212/SFML_Viewer.hpp"
#include "CME212/Util.hpp"
#include "CME212/Color.hpp"
#include "Graph.hpp"
// Define our types
using GraphType = Graph<int>;
using NodeType = typename GraphType::node_type;
using NodeIter = typename GraphType::node_iterator;
/** Find the node with the minimum euclidean distance to a point.
* @param g The graph of nodes to search.
* @param point The point to use as the query.
* @return An iterator to the node of @a g with the minimun Eucliean
* distance to @a point.
* graph.node_end() if graph.num_nodes() == 0.
*
* @post For all i, 0 <= i < graph.num_nodes(),
* norm(point - *result) <= norm(point - g.node(i).position())
*/
NodeIter nearest_node(const GraphType& g, const Point& point)
{
// HW1 #3: YOUR CODE HERE
(void) g, (void) point; // Quiet compiler warning
return g.node_end();
}
/** Update a graph with the shortest path lengths from a root node.
* @param[in,out] g Input graph
* @param[in,out] root Root node to start the search.
* @return The maximum path length found.
*
* @post root.value() == 0
* @post Graph has modified node values indicating the minimum path length
* to the root.
* @post Graph nodes that are unreachable from the root have value() == -1.
*
* This sets all nodes' value() to the length of the shortest path to
* the root node. The root's value() is 0. Nodes unreachable from
* the root have value() -1.
*/
int shortest_path_lengths(GraphType& g, NodeType& root)
{
// HW1 #3: YOUR CODE HERE
(void) g, (void) root; // Quiet compiler warnings
return 0;
}