Graph Theory

Graph theory is the study of graphs. A graph is a mathematical structure modeling pairwise relations between objects. In computer science, graphs represent networks, state machines, routing protocols, and data organization.

Formal Definition

A graph $G$ is a pair $(V, E)$:

An edge connecting vertices $u$ and $v$ is denoted as $e = {u, v}$.

Types of Graphs

TypeDescriptionExample
Undirected GraphEdges have no orientation. A connection between $u$ and $v$ goes both ways.Two-way roads
Directed Graph (Digraph)Edges have a specific direction, pointing from a source vertex to a destination vertex.One-way streets, web page links
Weighted GraphEach edge has an assigned numerical weight or cost.Distance maps, network routing tables
Complete GraphEvery pair of distinct vertices is connected by a unique edge.Peer-to-peer networks
Bipartite GraphVertices divide into two disjoint sets where every edge connects a vertex in one set to a vertex in the other.Job matching configurations

Graph Properties

Trees

A tree is a connected acyclic undirected graph. A directed acyclic graph is a DAG. Trees function as a foundational data structure in computer science.