graphs Flashcards
what are we given in shortest path problems
1-A weighted, directed graph G = (V, E)
2-Weight function w: E R mapping edges to real valued weights.
what is The weight w(p) of path
is the sum of the weights of its constituent edges
whats the shortest path from u to v
any path p between u and v with minimum weight
what is Single-source shortest path problem
its where we need to find shortest path from given source s∈V to each distanation in v∈V
talk about shortest path problems and edges whose weights are negative
there is two ways that negative edges can go or form in the graph:
1-(acceptable)If the **graph G (V,E) contains no negative-weight cycles reachable from the source s, then for all v ∈ V **, the shortest-path weight remains well defined, even if it has a negative value.
.
2-(not-acceptable)If the graph contains a negative-weight cycle reachable from s, however, shortest-path weights are not well defined. No path from s to a vertex on the cycle can be the shortest
what is negative cycle
Negative cycle: directed cycle whose sum of edges costs is negative.
Can a shortest path contain a cycle?
bc we assume it has no cycles
thus
-It can not contain a positive-weight cycle.
-since we will be removing the cycle, it produces a new path with the same source and destination vertices and a lower path weight.
number of edges in single shortest path
|V|-1 edges even if there is cycle
bc:removing the cycle, it produces a new path with the same source and destination vertices and a lower path weight.
diffrences between dijkstra and bellman-ford algorthims
dikstrea: Assumes that all edge weights in the input graph are nonnegative
bellman:Allows negative-weight edges in the input graph and produce a correct answer as long as no negative-weight cycles are reachable from the source.
what is relaxation what do we need to intioalize before doing it
The process of relaxing an edge (u,v) consists of testing whether we can improve the shortest path to v found so far by going through u and, if so, updating v.d and v.  .
we need before doing to intialize all vertxis by:For each vertex v∈V, we maintain an attribute v.d, which is an upper bound on the weight of a shortest path from source s to v. We call v.d a shortest-path estimate
lise all
T or F: A relaxation step always decrease the value of the shortest-path estimate v.d and update v’s predecessor attribute v. .
F
A relaxation step may and may not decrease the value of the shortest-path estimate v.d and update v’s predecessor attribute v. .
write intilize-single-source method and what is it for
is to preapare the for relax method with:
1-intilaize all vertixes vlaues(that costed to reach them)
.
2-intinlize all predecosr for given vertics
write the code for relax method
a propertiy in dikestra algorthim
Dijkstra’s algorithm maintains a set S of vertices whose final shortest-path weights from the source s have already been determined