

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Various graph algorithms, including dijkstra's algorithm, and their running times and complexities. Topics covered include dijkstra's running time, extract-min and decrease-key operations, and the relationship between different queue implementations. The document also mentions other graph algorithms such as bfs, dfs, topology sorting, and minimum spanning trees (prim and kruskal).
Typology: Assignments
1 / 25
This page cannot be seen from the preview
Don't miss anything!


















-^
-^
-^
-^
-^
-^
-^
-^
Two algorithms for systematically discovering
the
topology and layout
of a graph from a particular vertex
of the graph^ –
Breadth-first search
begins at a vertex and visits all vertices
which can be reached directly from that node, then repeats thevisitation from each new vertex discovered (good for discoveringshortest paths)
-^
Depth-first search
is similar, except it explores entire paths in
turn -- paths from a single neighbor of the starting vertex areexhaustively visited before the next neighbor is considered
Ordering
nodes in acyclic directed graphs
-^
strong connected components
minimum
spanning trees of a graph• But if
every edge has a
unique weight
, then there is a
unique MST
-^
cause a cycle
-^
outgoing
edge to add
-^
A graph
is said to be
k
-colorable if its vertices can be
colored with
k
different colors such that
no two adjacent vertices share the same color. 1:
Describe a polynomial-time algorithm to solve the graph-2-colorability problem. 2: Show that graph-4-colorability problem is NP-Complete.
Hint: graph-3-colorability is NP-Complete
Graph Algorithms
Method
: use BFS search tree
Recall
: BFS is a rooted spanning tree having the same layers as the original graph G (each node has the same distance from the root in BFS tree andin graph G) Algorithm
:
-^
Run BFS search and colour all nodes in odd layers red, others blue
-^
Go through all edges in adjacency list and check if each of them has twodifferent colours at its ends - if so then G is bipartite, otherwise it is not We use the following alternative definitions in the analysis:•^
Graph G = (V,E) is bipartite iff all its cycles have even length, or
-^
Graph G = (V,E) is bipartite iff it has no odd cycle
non bipartite
bipartite
Graph Algorithms
14
Property of layers: •^
Every edge is either between two consecutive layers or in a single layer (twoends are in the same layer) - it follows from BFS property
Suppose that graph G is
not bipartite
. Hence there is an odd cycle. This cycle
must have an edge in one layer, and so the ends of this edge have the samecolour. Thus the algorithm answers
not bipartite
correctly.
Suppose that graph G is
bipartite
. Hence all its cycles have even length.
Suppose, to the contrary, that the algorithm answers incorrectly that G is
not
bipartite
. Hence it found a monochromatic edge. This edge must be in one layer.
Consider one of such edges which is in the smallest possible layer. Consider acycle containing this edge and the BFS path between its two ends. The length ofthis cycle is odd, thus G is
not bipartite
. Contradiction!
not bipartite
bipartite
-^
e
in E with
c
f^ we put weight
c
-^ f^ (
residual
capacity
)
e
= (
u,v
) in E we put weight
f (
e ) to backward
edge (
v,u
) (
residual capacity
)
-^ Add node
s, t
t
is a maximummatching in G.
G
′
-^