cs 225
play

CS 225 Data Structures No Novem ember er 12 Gr Graphs aphs - PowerPoint PPT Presentation

CS 225 Data Structures No Novem ember er 12 Gr Graphs aphs Wa Wade Fagen-Ul Ulmschneider Gr Grap aphs To study all of these structures: 1. A common vocabulary 2. Graph implementations 3. Graph traversals 4. Graph algorithms


  1. CS 225 Data Structures No Novem ember er 12 – Gr Graphs aphs Wa Wade Fagen-Ul Ulmschneider

  2. Gr Grap aphs To study all of these structures: 1. A common vocabulary 2. Graph implementations 3. Graph traversals 4. Graph algorithms

  3. Incident Edges: Grap Gr aph V Vocab abular lary I(v) = { (x, v) in E } Degree(v): |I| G = (V, E) |V| = n Adjacent Vertices: |E| = m (2, 5) A(v) = { x : (x, v) in E } Path(G 2 ): Sequence of vertices connected by edges Cycle(G 1 ): Path with a common begin and end vertex. G 3 Simple Graph(G): A graph with G 2 no self loops or multi-edges. G 1

  4. Subgraph(G): Gr Grap aph V Vocab abular lary G’ = (V’, E’): V’ ∈ V, E’ ∈ E, and G = (V, E) (u, v) ∈ E à u ∈ V’, v ∈ V’ |V| = n |E| = m (2, 5) Complete subgraph(G) Connected subgraph(G) Connected component(G) Acyclic subgraph(G) Spanning tree(G) G 3 G 2 G 1

  5. Running times are often reported by n , the number of vertices, but often depend on m , the number of edges. How many edges? Minimum edges: Not Connected: V Connected*: a b U d X Z h c e Maximum edges: W g Simple: f Y Not simple:

  6. Con Connected Graphs

  7. Pr Proving the size of a minimally connected graph Theorem: Every connected graph G=(V, E) has at least |V|-1 edges.

  8. Thm: Every connected graph G=(V, E) has at least |V|-1 edges. Proof: Consider an arbitrary, connected graph G=(V, E) .

  9. Suppose |V| = 1: Definition: A connected graph of 1 vertex has 0 edges. Theorem: |V|-1 edges è 1-1 = 0.

  10. Inductive Hypothesis: For any j < |V| , any connected graph of j vertices has at least j-1 edges.

  11. Suppose |V| > 1: 1. Choose any vertex: V a 2. Partition: U X Z h c e W f Y

  12. Suppose |V| > 1: V a 3. Count the edges U X Z h c e W f Y

  13. Gr Grap aph A ADT Functions: - insertVertex(K key); Data: - insertEdge(Vertex v1, Vertex v2, K key); - Vertices - Edges - removeVertex(Vertex v); - Some data structure - removeEdge(Vertex v1, Vertex v2); maintaining the structure between vertices and edges. - incidentEdges(Vertex v); - areAdjacent(Vertex v1, Vertex v2); V b d X Z h - origin(Edge e); e - destination(Edge e); W g f Y

  14. Gr Grap aph I Imple lementatio tion: E : Edge L Lis ist u a c b d insertVertex(K key); v w z removeVertex(Vertex v); u a areAdjacent(Vertex v1, Vertex v2); v b w c incidentEdges(Vertex v); z d

  15. Gr Grap aph I Imple lementatio tion: A : Adjace acency cy M Matr trix ix insertVertex(K key); u removeVertex(Vertex v); a c areAdjacent(Vertex v1, Vertex v2); b d incidentEdges(Vertex v); v w z u v w z u a u v b v w c w z d z

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