There are several variations according to whether the given graph is undirected, directed, or mixed. For undirected graphs, the shortest path problem can be formally defined as follows. Given a weighted graph (that is, a set V of vertices, a set E of edges, and a real-valued weight function f : E → R), and elements v and v' of V, find a path P (a sequence of edges) from v to a v' of V so that