






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of graphs and graph algorithms, including graph implementation using adjacency matrix, list, and set, spanning trees, minimum spanning trees using prim's and kruskal's algorithms, and dijkstra's algorithm for shortest paths. It covers the basics of graph theory, data structures, and algorithms.
Typology: Study notes
1 / 30
This page cannot be seen from the preview
Don't miss anything!























Overview
Adjacency Matrix
⇒⇒⇒⇒^ edge between nodes n
, njk
Unweighted graph^ Matrix elements
⇒⇒⇒⇒^ boolean Weighted graph^ Matrix elements
⇒⇒⇒⇒^ weight
Adjacency Matrix
Adjacency List
Adjacency List
Graph Space Requirements Adjacency matrix^2 ½ Nentries (for graph with N nodes, E edges) Many empty entries for large graphs Adjacency list E entries Adjacency Set/Map E entries Space overhead per entry higher than for adjacencylist
Graph Time Requirements
Adj Set/Map O(1)O(1)O(1) O(E/N) O(E/N) O(1) Find edge
Enumerateedges
Delete edge
Insert edge
Adj List Adj Matrix Operation
Recursive Spanning Tree
Construction
Spanning Tree Construction
Depth-First Spanning Tree Example
Breadth-First Spanning Tree Example
Minimum Spanning Tree (MST) Spanning tree with minimum total edge weight Multiple MSTs possible (with same weight)
Algorithms for MST