Javatpoint Logo
Javatpoint Logo

Representing: Shortest Path

Given a graph G = (V, E), we maintain for each vertex v ∈ V a predecessor π [v] that is either another vertex or NIL. During the execution of shortest paths algorithms, however, the π values need not indicate shortest paths. As in breadth-first search, we shall be interested in the predecessor subgraph Gn= (Vn,En) induced by the value π. Here again, we define the vertex set Vπ, to be the set of vertices of G with non - NIL predecessors, plus the source s:

Vπ= {v ∈ V: π [v] ≠ NIL} ∪ {s} }

The directed edge set EΠ is the set of edges induced by the Π values for vertices in VΠ:

EΠ= {(Π[v], v) ∈ E: v ∈ VΠ - {s}}

A shortest - paths tree rooted at s is a directed subgraph G = (V' E'), where V'∈ V andE'∈E, such that

  1. V' is the set of vertices reachable from s in G
  2. G' forms a rooted tree with root s, and
  3. For all v ∈ V', the unique, simple path from s to v in G' is the shortest path from s to v in G.

Shortest paths are not naturally unique, and neither is shortest - paths trees.

Properties of Shortest Path:

1. Optimal substructure property: All subpaths of shortest paths are shortest paths.

Representing: Shortest Path

Let P1 be x - y sub path of shortest s - v path. Let P2 be any x - y path. Then cost of P1≤ cost of P2,otherwise P not shortest s - v path.

2. Triangle inequality: Let d (v, w) be the length of shortest path from v to w. Then,
d (v, w) ≤ d (v, x) + d (x, w)

Representing: Shortest Path

3. Upper-bound property: We always have d[v] ≥ δ(s, v) for all vertices v ∈ V, and once d[v] conclude the value δ(s, v), it never changes.

4. No-path property: If there is no path from s to v, then we regularly have d[v] = δ(s, v) = ∞.

5. Convergence property: If s->u->v is a shortest path in G for some u, v ∈ V, and if d[u] = δ(s, u) at any time prior to relaxing edge (u, v), then d[v] = δ(s, v) at all times thereafter.

Next TopicRelaxation




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA