graph algorithms
play

Graph Algorithms CptS 223 Advanced Data Structures Larry Holder - PowerPoint PPT Presentation

Graph Algorithms CptS 223 Advanced Data Structures Larry Holder School of Electrical Engineering and Computer Science Washington State University 1 2 Internet Web Network Social Graphs Protein-protein Power Interaction Grid Some


  1. Graph Algorithms CptS 223 – Advanced Data Structures Larry Holder School of Electrical Engineering and Computer Science Washington State University 1

  2. 2 Internet Web Network Social Graphs Protein-protein Power Interaction Grid

  3. Some Graph Statistics � Web � 10B pages, 1T hyperlinks � Topology storage: 10TB � Google PageRank: Eigenvector on 10Bx10B adjacency matrix (sparse) � MySpace � 100M users, 10B friendship links � Clique/community detection � 300K new users per day 3

  4. Graph Problems � Degree � Clustering � Diameter � Partitioning � Centrality � Cliques � Shortest path � Motifs � Cycles/tours � Subgraph isomorphism � Minimum spanning tree � Frequent subgraphs � Traversals/search � Pattern learning � Connectivity � Dynamics 4

  5. Definitions � Graph G = (V,E) consists of vertices V and edges E � E = { (u,v) | u,v ∈ V} � v is adjacent to u � E.g., � V = { A,B,C,D,E,F,G} � E = { (A,B), (A,D), (B,C), (C,D), (C,G), (D,E), (D,F), (E,F)} 5

  6. Definitions � Undirected graph � Edges are unordered � Directed graph � Edges are ordered � Weighted graph � Edges have a weight w(u,v) or cost c(u,v) 6

  7. Definitions � Degree of a vertex � Number of edges incident on a vertex � Indegree degree(v 4 ) = 6 � Number of directed indegree(v 4 ) = 3 outdegree(v 4 ) = 3 edges to vertex indegree(v 1 ) = 0 � Outdegree outdegree(v 1 ) = 3 � Number of directed indegree(v 6 ) = 3 edges from vertex outdegree(v 6 ) = 0 7

  8. Definitions � Path � Sequence of vertices v 1 , v 2 , …, v N such that (v i ,v i+ 1 ) ∈ E for 1 ≤ i < N � Path length is number of edges on path (N-1) � Simple path has unique intermediate vertices � Cycle � Path where v 1 = v N � Usually simple and directed � Acyclic graphs have no cycles 8

  9. Definitions � Undirected graph is connected if there is a path between every pair of vertices � Connected, directed graph is called strongly connected � Complete graph has an edge between every pair of vertices 9

  10. 10 Representation

  11. Topological Sort � Order vertices in a directed, acyclic graph such that if (u,v) ∈ E, then u before v in the ordering Topological order: v1, v2, v5, v4, v3, v7, v6 11

  12. Topological Sort � Solution # 1 � While vertices left in graph // O(|V|) � Find vertex v with indegree = 0 // O(|V|) � Output v � Remove edges to/from v � T(V,E) = O(|V| 2 ) Topological order: v1, v2, v5, v4, v3, v7, v6 12

  13. Topological Sort � Solution # 2 � Don’t need to search all vertices for indegree = 0 � Only vertices who lost an edge from the previous vertex’s removal � T(V,E) = O(|V| + |E|) � Note: |E| = O(|V| 2 ) Topological order: v1, v2, v5, v4, v3, v7, v6 13

  14. 14

  15. 15 Topological Sort

  16. Graph Algorithms � Topological Sort � Shortest paths � Network flow � Minimum spanning tree � Applications � NP-Completeness 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend