graphs c Flashcards

1
Q

what are we given in shortest path problems

A

1-A weighted, directed graph G = (V, E)
2-Weight function w: E  R mapping edges to real valued weights.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is The weight w(p) of path

A

is the sum of the weights of its constituent edges

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

whats the shortest path from u to v

A

any path p between u and v with minimum weight

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is Single-source shortest path problem

A

its where we need to find shortest path from given source s∈V to each distanation in v∈V

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

talk about shortest path problems and edges whose weights are negative

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is negative cycle

A

Negative cycle: directed cycle whose sum of edges costs is negative.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can a shortest path contain a cycle?

A

-It can not contain a positive-weight cycle.
-When removing the cycle, it produces a new path with the same source and destination vertices and a lower path weight.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

number of edges in single shortest path

A

|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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

diffrences between dijkstra and bellman-ford algorthims

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is relaxation what do we need to intioalize before doing it

A

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 it is 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

lise all

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

T or F: A relaxation step always decrease the value of the shortest-path estimate v.d and update v’s predecessor attribute v. .

A

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. .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

write intilize-single-source method and what is it for

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

write the code for relax method

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is dikestra algorthim

A

Dijkstra’s algorithm maintains a set S of vertices whose final shortest-path weights from the source s have already been determined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

write dikjstra algorthim and all its components

A
17
Q

Analysis of Dijkstra’s Algorithm if we bulid Q as array

A
18
Q

Analysis of Dijkstra’s Algorithm if we bulid Q as array

A
19
Q

solve

A
20
Q

what can effect the running time of dijkstra

A

The running time depends on how we implement the min-priority queue Q.
Array
Min-heap

21
Q

bellman-ford proprties

A

1-Allows negative-weight edges.
2-Computes d[v] and [v] for all v ∈ V .
3-Returns TRUE if no negative-weight cycles reachable from s, FALSE otherwise.
4-The algorithm makes |V|-1 passes.
Bellman Ford’s Algorithm is slower than Dijkstra’s algorithm
5-Each pass relaxes all edges of the graph.

22
Q

quickest single shortest path algorthim

A

dijkstra algorthim

23
Q

signficunt propertiy in bell-man algorthim

A

it relaxes all edges of the graph with each pass.

24
Q

write psudocode for bellaman-ford algorthim

A
25
Q

slove

A
26
Q

Analysis of Bellman-ford Algorithm

A