08_Graphs - CpE 354B Data Structures and Algorithms Graphs Dr Mohammed Dmaithan Halloush 1 Graph Terminology vertex node point edge line arc G =(V E V

08_Graphs - CpE 354B Data Structures and Algorithms Graphs...

This preview shows page 1 - 11 out of 43 pages.

1 1 Graphs Dr. Mohammed Dmaithan Halloush CpE 354B: Data Structures and Algorithms Graph Terminology vertex, node, point edge, line, arc G = (V, E) – V is set of vertices – E is set of edges Each edge joins two vertices 2
Image of page 1
2 Undirected Graph Edges do not have a direction The edge from 1 to 2 is also an edge from 2 to 1 Edge (1, 2) implies that there is also an edge (2, 1) [ The same edge ] 3 Directed Graph Edges have a direction Edge (2, 1) means only that there is an edge from 2 to 1 In this example, there is no edge from 1 to 2 4
Image of page 2
3 Directed vs. Undirected Graph An undirected graph is one in which the pair of vertices in a edge is unordered, (v 0 , v 1 ) = (v 1 ,v 0 ) A directed graph is one in which each edge is a directed pair of vertices, <v 0 , v 1 > != <v 1 ,v 0 > tail head Weighted Graph weights (values) are associated with the edges in the graph May be directed or undirected Weighted graphs are also referred to as networks 6
Image of page 3
4 Complete Graph For each pair of vertices, there is one edge If G = (V, E) is a complete graph, and |V| = n, then can you calculate |E|? 7 Complete Graph 8 ) ( 2 ) 1 ( ! 2 )! 2 ( ! 2 2 v O v v v v v = - = - = For each pair of distinct vertices there is exactly one edge connecting them Number of edges is:
Image of page 4
5 Connectivity Let n = #vertices , and m = #edges A complete graph : Each of the n vertices is incident to n -1 edges, however, we would have counted each edge twice! Therefore, intuitively, m = n ( n -1)/2. Therefore, if a graph is not complete, m < n ( n -1)/2 n = 5 m = (5 * 4)/2 = 10 Subgraph Subset of vertices and edges forming a graph A subgraph G’ of graph G = (V, E) is a graph (V’, E’) that V’ V and E’ E. 10
Image of page 5
6 Degree of vertex The number of edges incident with v • Deg(v)=0 barb2right isolated vertex 11 12 Path The sequence of edges (v 1 , v 2 ), (v 2 , v 3 ),…,(v k-1 , v k ). Denoted as path v 1 , v 2 , ..., v k such that consecutive vertices v i and v i+1 are adjacent. Length of path is sum of the lengths of the edges a d e c b a b c d e a b c d e a b e d c b e d c
Image of page 6
7 More Terminology simple path : no repeated vertices cycle : simple path, except that the last vertex is the same as the first vertex a b c d e b e c Even More Terminology connected component : maximal connected subgraph. E.g., the graph below has 3 connected components. connected not connected •connected graph : any two or more vertices are connected by some path
Image of page 7
8 tree - connected graph without cycles. unique path between every pair of vertices forest - collection of trees tree for est tree tree tree Connectivity n = #vertices m = #edges For a tree m = n - 1 n = 5 m = 4 n = 5 m = 3 If m < n - 1, G is not connected
Image of page 8
9 Size of a Graph • Graph G = (V,E) n = |V| = # vertices m = |E| = # edges size of G is n+m 4 2 3 1 Representation of Graphs Adjacency matrix Incidence matrix Adjacency lists: Table, Linked List Space/time trade-offs depending on which operation are most frequent as well as properties of the graph 18
Image of page 9
10 Let G=(V,E) be a graph with n vertices.
Image of page 10
Image of page 11

You've reached the end of your free preview.

Want to read all 43 pages?

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes