Graphs and its Applications
Learning about graphs is a fundamental part of understanding algorithms and data structures, and it’s widely applicable in many areas like network routing, social networks, and even game development.
What is a Graph?: A graph is a collection of vertices (nodes) connected by edges.
Graphs can be either directed or undirected. Directed Graph: If Edges in graph have a direction, It is called directed graph. i.e., they go from one node to another (like one-way streets).
Undirected Graph: If Edges in graph have a no direction, it is a undirected graph (like two-way streets).
Key Terminologies:
- Vertex (Node): A fundamental unit represented in a graph (e.g., a city in a map).
- Edge: A connection between two vertices (e.g., a road connecting two cities).
- Adjacency: If there’s an edge between two nodes, they are adjacent nodes.
- Path: A sequence of nodes where each adjacent pair is connected by an edge.
- Cycle Path: A path that starts and ends at the same node.
- Connected Graph: If every pair of nodes has a path between them.
- Acyclic Graph: A graph with no cycles (cyclic path).
- Weighted Graph: A graph where edges have weights…