1. Introduction to Graphs
- Graph = Non-linear data structure consisting of vertices (nodes) and edges (connections).
- Vertices (V) – Represent entities.
- Edges (E) – Represent relationships between vertices.
- Graph Representation:
- Adjacency Matrix – 2D array; 1 if edge exists, 0 otherwise.
- Adjacency List – List of neighbors for each vertex; memory-efficient for sparse graphs.
- Adjacency Matrix – 2D array; 1 if edge exists, 0 otherwise.
2. Types of Graphs
- Undirected Graph – Edges have no direction.
- Directed Graph (Digraph) – Edges have a direction.
- Weighted Graph – Each edge has a weight (cost, distance).
- Unweighted Graph – Edges have no weight.
- Connected Graph – Path exists between all vertex pairs.
- Disconnected Graph – Some vertices are isolated.
3. Graph as an Abstract Data Type (ADT)
- ADT Operations:
- AddVertex(v) – Add new vertex.
- AddEdge(u, v) – Add edge between vertices u and v.
- RemoveVertex(v) – Delete vertex and its edges.
- RemoveEdge(u, v) – Delete edge between u and v.
- TraverseGraph() – Visit all vertices (DFS/BFS).
- AddVertex(v) – Add new vertex.
4. Graph Traversal
- Breadth-First Search (BFS)
- Level-wise traversal using queue.
- Finds shortest path in unweighted graphs.
- Level-wise traversal using queue.
- Depth-First Search (DFS)
- Traverses as far as possible along a branch using recursion or stack.
- Useful for detecting cycles, connectivity, topological sorting.
- Traverses as far as possible along a branch using recursion or stack.
5. Shortest Path & Spanning Trees
- Shortest Path Algorithm – Find minimum path between vertices:
- Dijkstra’s Algorithm – Weighted graph with non-negative edges.
- Dijkstra’s Algorithm – Weighted graph with non-negative edges.
- Minimum Spanning Tree (MST) – Subset of edges connecting all vertices with minimum total weight:
- Kruskal’s Algorithm – Greedy, sorts edges by weight.
- Prim’s Algorithm – Greedy, expands tree one vertex at a time.
- Kruskal’s Algorithm – Greedy, sorts edges by weight.
6. Transitive Closure
- Determines reachability between all pairs of vertices.
- Warshall’s Algorithm – Efficient method using adjacency matrix.
7. Applications of Graphs
- Network Routing – Internet packet routing, shortest path.
- Social Networks – Represent connections among users.
- Project Scheduling – PERT/CPM uses directed acyclic graphs.
- Circuit Design – Represent dependencies among components.
- Game Theory / AI – Decision trees, game trees.
✅ Key Takeaways – Unit 10
- Graph = vertices + edges; represented by matrix or list.
- Traversal: BFS (queue), DFS (stack/recursion).
- Shortest path: Dijkstra, Minimum Spanning Tree: Kruskal/Prim.
- Applications in networking, scheduling, AI, social graphs.
- ADT operations include add/remove vertex/edge, traverse, search.