A Graph (G) is a mathematical structure consisting of two sets: a set of Vertices (V) (also called nodes) and a set of Edges (E) that connect pairs of vertices.
Formal Notation: G = (V, E).
Example: V = \{v1, v2, v3\}, E = \{(v1, v2), (v2, v3)\}.
Graphs are classified based on the nature of their edges and connections:
| Type | Description |
|---|---|
| Undirected Graph | Edges have no direction (connection is two-way). |
| Directed Graph (Digraph) | Edges have a specific direction (represented by arrows). |
| Simple Graph | A graph with no self-loops and no multiple edges between the same vertices. |
| Complete Graph (Kn) | A graph where every vertex is connected to every other vertex exactly once. |
The Degree of a vertex is the number of edges incident (connected) to it. For directed graphs, we distinguish between In-degree (arrows coming in) and Out-degree (arrows going out).
Handshaking Lemma: The sum of the degrees of all vertices in a graph is twice the number of edges.
∑ deg(v) = 2 × |E|
A Tree is a special type of connected graph that has no cycles. Trees are fundamental in computer science for organizing data (like folder structures or HTML DOM).
Q: What is an Isolated Vertex?
A: A vertex with a degree of 0 (no connections).
Q: What is a Pendant Vertex?
A: A vertex with a degree of 1 (a "leaf" in a tree).
Q: Why is Graph Theory important for BCA?
A: It is used in networking (topology), database management (relationships), and algorithm design (pathfinding).