Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 ELEC692 Fall 2004 Lecture 1b ELEC692 Lecture 1a Introduction to graph theory and algorithm.

Similar presentations


Presentation on theme: "1 ELEC692 Fall 2004 Lecture 1b ELEC692 Lecture 1a Introduction to graph theory and algorithm."— Presentation transcript:

1 1 ELEC692 Fall 2004 Lecture 1b ELEC692 Lecture 1a Introduction to graph theory and algorithm

2 2 ELEC692 Fall 2004 Lecture 1b Graphs  A graph G(V,E) is a pair (V,E) where V is a set of vertices and E is a binary relation on V which is called the edges of the graph.  In a directed graph, the edges are ordered pairs or vertices; in an undirected graph, the edges are unordered pairs.  Degree of a vertex (node) = number of edges incident to it.  Hypergraph - extension of a graph where edges may be incident to any number of vertices, Undirected graphdirected graphHypergraph

3 3 ELEC692 Fall 2004 Lecture 1b Undirected Graphs (I)  A vertex is adjacent to another if there is an edge incident to both of them.  Loop-an edge with two identical end-points  A graph is simple if it has no loop and two edges link the same vertex pair. Otherwise it is called multi-graph.  A walk is an alternating sequence of vertices and edges and a trail is a walk with distinct edges and a path is a trail with distinct vertices.  A cycle is a closed walk with distinct vertices.  A graph is connected if all vertex pairs are joined by a path.  A graph with no cycles is called an acyclic graph. ab cd 1 2 3 4 5 loop a is adjacent to b The graph is simple if the loop is removed. (a,1,b,2,d,5,a,1) is a walk. (a,1,b,2,d,5,a,4) is a trail. (a,1,b,2,d,3,c,4) is a path. (a,1,b,2,d,5,a) is a cycle. The graph is a connected. It is not an acyclic graph.

4 4 ELEC692 Fall 2004 Lecture 1b Undirected Graphs (II)  A tree is a connected acyclic graph. A rooted tree is a tree with a distinct vertex called root.  Vertices of a tree are called nodes. Nodes that are only connected to one vertex are called leaves.  A cutset is a minimal set of edges whose removal from the graph makes it disconnected. Similarly a vertex separation set is a minimal set of vertex whose removal from the graph makes it disconnected.  A complete graph is one such that each vertex pair is joined by an edge. A complement of a graph G(V,E) is a graph with V and two vertices are adjacent iff they are not adjacent in G.  A bipartite graph is a graph where the vertex set can be partitioned into 2 subsets such that each edge has end-points in different subsets. ab cd 1 24 root leaves 1 ab cd 24 3 56 A complete graph {1,4,6} is a cutset {a} is a vertex sep. set ab cd 24 56

5 5 ELEC692 Fall 2004 Lecture 1b Undirected Graphs (III)  A subgraph of a graph V(G,E) is a graph whose vertex and edge sets are contained in the vertex and edges set of G. Give a vertex set U contains in V, the subgraph induced by U is the maximal subgraph of G(V,E), whose edges have end-points in U.  A clique of a graph is a complete subgraph.  A clique is maximal when it is not contained in other clique.  A graph is planar if it has a diagram on a plane surface such that no two edges cross.  Two graphs are said to be isomorphic if there is a one-to-one correspondence between their vertex sets that preserves adjacency. maximal clique planar isomorphic

6 6 ELEC692 Fall 2004 Lecture 1b Directed Graph  For any directed edge (v i, v j ), vertex v j is called the head and v i is the tail.  The indegree of a vertex is the number of edges where it is the head, the outdegree the number of edges where it is the tail.  Directed acyclic graphs (DAGS) represent partially ordered sets. In a DAG, a vertex v j is called the successor (or descendant) of a vertex v i if v j is the head of a path whose tail is v i.  A polar dag is a graph having two distinguished vertices, a source and a sink and where all vertices are reachable from the source and where the sink are reachable from all vertices.  Directed and undirected graphs can be weighted. Weights can be associated with vertices and/or with edges.

7 7 ELEC692 Fall 2004 Lecture 1b Matrix Representation  Incidence matrix and adjacency matrix. 12 4 3 a b c d e a b c d e 12341234 -1 0 0 -1 -1 1 -1 0 0 0 0 1 -1 0 1 0 0 1 1 0 Incidence matrix 1 2 3 4 12341234 0 1 1 1 0 0 1 0 0 0 0 1 0 0 0 0 Adjacency matrix

8 8 ELEC692 Fall 2004 Lecture 1b Graph optimization problems and algorithms - Shortest/Longest path  Model Directed graph G(V,E) with N vertices Weights on each edge A source vertex  Single source shortest path problem find shortest path from the source to any vertex Inconsistent problem:  negative-weighted cycles  Bellman’s equations:path weight to a vertex in terms of the path weight to its direct predecessors:

9 9 ELEC692 Fall 2004 Lecture 1b Shortest Path Problem  Acyclic graphs: Topological sort O(n 2 ),  All positive weights - Dikstra’s algorithm (greedy) Complexity = O(|E| + |V| log |V|) Dijkstra (G(V,E,W)) { s 0 = 0; all other s i = infinity for (i= 1 to N) s i = w 0,i ; repeat { select unmarked v q s.t. s q is minimal; mark v q ; foreach (unmarked vertex v i ) s i = min{s i,(s q + w q,i )} } until (all vertices are marked) }

10 10 ELEC692 Fall 2004 Lecture 1b Example- Dikstra’s algorithm 0 u x y s 10 1 2 3 5 2 7 9 4 6 0 u x y s 1 2 3 5 2 7 9 4 6 v v v 0 u x y s 1 2 3 5 2 7 9 4 6 v 0 u x y s 1 2 3 5 2 7 9 4 6 5 5 814 7 57 813 v 0 u x y s 10 1 2 3 5 2 7 9 4 6 57 89 v 0 u x y s 1 2 3 5 2 7 9 4 6 57 89

11 11 ELEC692 Fall 2004 Lecture 1b Shortest Path Problem  Graph has cycles and sign of weights is not restricted.  Bellman-Ford algorithm - solve Bellman’s equation by relaxation. Complexity O(|V||E|) < O(n 3 ) Bellman_ford (G(V,E,W)) { s 0 1 = 0; for (i= 1 to N) s i 1 = w 0,i ; for( j= 1 to N) for (i=1 to N) } if (s i j+1 = = s i j for all i } return (TRUE); } return (FALSE) }

12 12 ELEC692 Fall 2004 Lecture 1b Lonest Path Problem  Use shortest path algorithms: by reversing signs on weights  Modify algorithms: by changing min with max  Remarks: Dijkstra’s algorithm is not relevant Inconsistent problem  positive-weighted cycles

13 13 ELEC692 Fall 2004 Lecture 1b Example - Bellman-Ford 1 2 03 6 -3 1 -4 Iteration 0: l 0 = 0; l 1 = -3; l 2 =-1; l 3 = Iteration 1: l 0 = 0; l 1 = -3; l 2 =-2; l 3 =-5 Iteration 2: l 0 = 0; l 1 = -3; l 2 =-2; l 3 =-6 Iteration 3: l 0 = 0; l 1 = -3; l 2 =-2; l 3 =-6


Download ppt "1 ELEC692 Fall 2004 Lecture 1b ELEC692 Lecture 1a Introduction to graph theory and algorithm."

Similar presentations


Ads by Google