Download Download Presentation Upon completion you will be able to: Understand and use basic graph terminology and concepts

# Upon completion you will be able to: Understand and use basic graph terminology and concepts

Download Presentation ## Upon completion you will be able to: Understand and use basic graph terminology and concepts

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
##### Presentation Transcript

1. Graphs • Upon completion you will be able to: • Understand and use basic graph terminology and concepts • Define and discuss basic graph and network structures • Design and implement graph and network applications • Design and implement applications using the graph ADT • Define and discuss Dijkstra's shortest path algorithm Data Structures: A Pseudocode Approach with C, Second Edition

2. 11-1 Basic Concepts • A graph is a collection of nodes, called vertices, and a collection of segments, called lines or edges, connecting pairs of vertices. In Basic Concepts we develop the terminology and structure for graphs. In addition to the graph definitions, discussion points include: • Directed and Undirected Graphs • Cycles and Loops • Connected and Disjoint Graphs Data Structures: A Pseudocode Approach with C, Second Edition

3. A directed graph or digraph for short, is a graph in which line has a direction (arrow head) to its successor. The lines in a directed graphs are known as arcs. • An undirected graph is a graph in which there is no direction on the lines, known as edges. Data Structures: A Pseudocode Approach with C, Second Edition

4. Two vertices in a graph are said to be adjacent vertices if there exists an edge that directly connects them. • A path is a sequence of vertices in which each vertex is adjacent to the next one. It does not make any difference whether or not the graph is directed, it may still have paths. In an undirected graph, you may travel in either directions. Simple path is a path such that all its vertices and edges are distinct. • A cycle is a path consisting of at least three vertices that starts and ends with the same vertex. • A loop is a special case of a cycle in which a single arc begins and ends with the same vertex. In a loop, the end points of the edge are the same. Data Structures: A Pseudocode Approach with C, Second Edition

5. Two vertices are said to be connectedif there is a path between them. A graph is said to be connected if, suppressing direction, there is a path from any vertex to any other vertex. • A directed graph is strongly connected if there is a path from each vertex to every other vertex in the digraph. • A directed graph is weakly connected when there are at least two vertices that are not connected. • A graph is disjoint if it is not connected. • The degree of a vertex is the number of lines incident to it. • The outdegree of a vertex in a digraph is the number of arcs leaving the vertex. • The indegree is the number of arcs entering the vertex. Data Structures: A Pseudocode Approach with C, Second Edition

6. 11-2 Operations • We define and discuss the six primitive graph operations required to maintain a graph. • Insert Vertex • Delete Vertex • Add Edge • Delete Edge • Find Vertex • Traverse Graph Data Structures: A Pseudocode Approach with C, Second Edition

7. We begin by pushing the 1st vertex, A, into the stack. • We then loop, popping the stack and after processing the vertex, pushing all of the adjacent vertices into the stack. To process X at step 2, we pop Xfrom the stack, process it and then push G and H into the stack giving the stack contents for step 3 to process H and G. • When the stack is empty, the traversal is complete. Data Structures: A Pseudocode Approach with C, Second Edition

8. We begin by enqueuing vertex, A, in the queue. • We then loop, dequeuing the queue and processing the vertex from the front of the queue. After processing the vertex, we place all of its adjacent vertices into thequeue. We are then ready for the next step. • When the queue is empty, the traversal is complete. Data Structures: A Pseudocode Approach with C, Second Edition

9. 11-3 Graph Storage Structures • To represent a graph, we need to store two sets. The first set represents the vertices of the graph, and the second set represents the edges or arcs. The two most common structures used to store these sets are arrays and linked lists. • Adjacency Matrix • Adjacency List Data Structures: A Pseudocode Approach with C, Second Edition

10. 11-6 Networks • A network is a graph whose lines are weighted. It is also known as a weighted graph. Included in this section are two graph applications that process networks. • Minimum Spanning Tree • Shortest Path Algorithm Data Structures: A Pseudocode Approach with C, Second Edition

11. A spanning tree is a tree that contains all of the vertices in a graph. A minimum spanning tree is a spanning tree in which the total weight of the lines are guaranteed to be the minimum of all possible trees in the graph. If the weights are unique, then there will be only one minimum spanning tree. Minimum Spanning Tree Data Structures: A Pseudocode Approach with C, Second Edition

12. Algorithm of MST (Prim Algoritm) 1. Insert the first vertex (pick any vertex) into the tree 2. From every vertices already in the tree, examine the edges that connected to all adjacent vertices not in the tree. Select the edge with the minimum weight to a vertex not currently in the tree. Insert that minimum-weight edge and the vertex into the tree. 3. Repeat step 2 until all vertices are in the tree. Data Structures: A Pseudocode Approach with C, Second Edition

13. (continued) Data Structures: A Pseudocode Approach with C, Second Edition
{"ft_lang_label":"__label__en","ft_lang_prob":0.8995246,"math_prob":0.88065743,"size":6046,"snap":"2023-14-2023-23","text_gpt3_token_len":1314,"char_repetition_ratio":0.224429,"word_repetition_ratio":0.20801526,"special_character_ratio":0.20674826,"punctuation_ratio":0.11227154,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9859354,"pos_list":[0,1,2,3,4,5,6,7,8],"im_url_duplicate_count":[null,null,null,null,null,1,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-31T10:23:38Z\",\"WARC-Record-ID\":\"<urn:uuid:c8195eb7-e047-4dcb-a8ef-3059f23517c4>\",\"Content-Length\":\"95736\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:56d14540-5068-4f26-bbea-a424fc94ac7b>\",\"WARC-Concurrent-To\":\"<urn:uuid:e944f869-89e0-44e1-b1dd-373b249a8370>\",\"WARC-IP-Address\":\"35.160.78.151\",\"WARC-Target-URI\":\"https://www.slideserve.com/clyde/upon-completion-you-will-be-able-to-understand-and-use-basic-graph-terminology-and-concepts\",\"WARC-Payload-Digest\":\"sha1:OV4J2G73M4UJP7LBCVDOBLYTCMDBZVRY\",\"WARC-Block-Digest\":\"sha1:HMEDFM5UONBN7KWQFRTJO27TOPI2RK7I\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296949598.87_warc_CC-MAIN-20230331082653-20230331112653-00373.warc.gz\"}"}