Introduction to Graphs
Graphs are fundamental mathematical structures used to model relationships between entities. They are widely used in computer science, physics, social sciences, and engineering.
Graph Definition
A graph is formally defined as:
where:
\(V\) is a finite set of vertices (nodes)
\(E \subseteq V \times V\) is a set of edges
Each edge represents a relationship between two vertices.
Vertices and Edges
Let:
be the set of vertices.
An edge is defined as:
Thus, the edge set is:
Types of Graphs
Graphs can be categorized based on edge properties.
Undirected Graph
In an undirected graph, edges have no direction:
Thus:
Directed Graph (Digraph)
In a directed graph, edges are ordered pairs:
Here:
Each edge has a direction from \(u\) to \(v\).
Weighted Graph
A weighted graph assigns a numerical value to each edge.
where:
is a weight function.
Each edge is represented as:
Example (Weighted Edge Set)
Use Cases of Weighted Graphs
Weighted graphs are used when relationships have costs or distances:
Shortest path problems
Network routing
Transportation systems
Resource optimization
Recommendation systems
Graph Properties
Degree
The degree of a vertex \(v\) is:
For directed graphs:
In-degree:
Out-degree:
Path
A path is a sequence of vertices:
such that:
Cycle
A cycle is a path where:
Connectivity
A graph is connected if:
Graph Density
The density of a graph is defined as:
Graph Representations
Graphs can be represented in different ways.
Adjacency List
For each vertex:
Adjacency Matrix
A matrix \(A\) where:
For weighted graphs:
Summary
Graphs provide a powerful abstraction for modeling relationships. Understanding their mathematical formulation, types, and properties is essential for designing efficient algorithms and systems.
Note
This section focuses on the theoretical foundation of graphs. Practical implementations and algorithms are discussed in later sections.