




































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
Lecture from Object Oriented Programming and Data Structures course with following key points: Graphs, Representation, Adjacency Matrix, Shortest Paths in Graphs, Dijkstras Shortest Path Algorithm, Execution Time, Special Case, Matrix Representation
Typology: Slides
1 / 44
This page cannot be seen from the preview
Don't miss anything!





































Histogram: max: 28. [00:02): 17 av: 5. [02:04): 102 median: 4. [04:06): 134 [06:08): 50 [08:10): 29 [10:12): 8 [12:14): 6 [14:16): 2 [16:18): 1 [18:30): 5 If you took more than 6- 7 hours for this assignment, you may have been wasting your time. A certain amount of “floundering”, just trying things, is good. But after a point, it just wastes time. Seek help if after an hour on one of the recursion problems you are stuck.
5
Communication networks The internet is a huge graph Routing and shortest path problems Commodity distribution (flow) Traffic control Resource allocation Geometric modeling ...
V = {a,b,c,d,e,f } E = {(a,b), (a,c), (a,e), (b,c), (b,d), (b,e), (c,d), (c,f), (d,e), (d,f), (e,f)} |V| = 6, |E| = 11 b a c d e f
An undirected graph is just like a directed graph, except the edges are unordered pairs ( sets ) {u,v}
V = {a,b,c,d,e,f } E = {{a,b}, {a,c}, {a,e}, {b,c}, {b,d}, {b,e}, {c,d}, {c,f}, {d,e}, {d,f}, {e,f}} b a c d e f
path: sequence of adjacent vertexes length of path: number of edges simple path: no vertex is repeated simple path of length 2: (b, c, d) simple path of length 0: (b) not a simple path: (b, c, e, b, c, d) b c d e
cycle: path that ends at its beginning simple cycle: only repeated vertex is its beginning/end acyclic graph: graph with no cycles dag: directed acyclic graph b c d e cycles: (b, c, e, b) (b, c, e, b, c, e, b) simple cycle: (c, e, b, c) graph shown is not a dag Question: is (d) a cycle? No. A cycle must have at least one edge
Intuition: A dag has a vertex with indegree 0. Why? This idea leads to an algorithm: A digraph is a dag if and only if one can iteratively delete indegree-0 vertices until the graph disappears b a c d e f
Intuition: A dag has a vertex with indegree 0. Why? This idea leads to an algorithm: A digraph is a dag if and only if one can iteratively delete indegree-0 vertices until the graph disappears b c d e f
Intuition: A dag has a vertex with indegree 0. Why? This idea leads to an algorithm: A digraph is a dag if and only if one can iteratively delete indegree-0 vertices until the graph disappears d e f
Intuition: A dag has a vertex with indegree 0. Why? This idea leads to an algorithm: A digraph is a dag if and only if one can iteratively delete indegree-0 vertices until the graph disappears e f
We just computed a topological sort of the dag
Useful in job scheduling with precedence constraints
Coloring of an undirected graph: an assignment of a color to each node such that no two adjacent vertices get the same color How many colors are needed to color this graph?
b a c d e f