A graph is a pair
Properties
- the order of a graph is the number of vertices (written as
) - the size of a graph is the number of edges (written as
) - an edge
is usually written as (or ), if is an edge of then and are said to be adjacent in - a vertex
is incident with an edge e if - the set of neighbors of a vertex
is denoted by - the degree of a vertex
is the number of edges incident to (loops are counted twice)
Let
- if
then and are disjoint - if
and then is a subgraph of written as - if
is a subgraph of and either or then is a proper subgraph of - if
is a subgraph of and then is an spanning subgraph of - if
and all the edges so that and and also then is an induced graph of
Movement
A walk in a graph is a sequence of movements beginning at
where
- a trail is a walk in which no edge is traversed more than once
- a path is a walk in which no vertex is visited more than once (note that every path is also a trail)
- a circuit is a closed trail of length 3 or more (it begins and ends at the same vertex but repeat no edges)
- a cycle is a circuit that repeat no vertex (think of it as a closed path), a
-cycle is a cycle of length (e.g. a -cycle is a triangle)
Properties related with path lengths
- the distance between two vertices
and is the smallest length of any path in denoted by - the diameter is the greatest distance between any two vertices of a connected graph
Some additional properties related with connectivity in a graph
- if a graph
contains a path then and are said to be connected - a graph
is connected if every two vertices of are connected - a connected subgraph of
that is not a proper subgraph of any other connected subgraph of is a component of - the number of components of a graph is denoted by
, then a graph is connected if
Common classes of graphs
Complete graph
A graph
- a complete graph of order
is denoted by , for complete graphs has the maximum possible size for a graph of vertices - the number of pairs of vertices in
is
Sparse graph
A graph
Dense graph
A graph
Complement graph
The complement
- if
is diconnected, is connected
Bipartite graph
A graph
- a nontrivial graph
is bipartite if it doesn’t contain odd length cycles - a complete bipartite graph is a bipartite graph where each vertex of
is adjacent to every vertex of , it’s denoted as - a star is a complete bipartite graph where
or
-partite graph
A graph
Biconnected graph
A biconnected graph
Multigraphs
A multigraph
Pseudographs
A pseudograph
Weighted graph
Let
Digraphs
A directed graph
- if
is a directed edge then is adjacent to and is adjacent from
Degrees
The degree of a vertex
- the minimum degree of a graph
is the minimum degree among all the vertices of denoted as - the maximum degree of a graph
is the maximum degree among all the vertices of denoted as - a vertex of degree
is called an isolated vertex - a vertex of degree
is called an end vertex (or leaf) - a vertex of even degree is called an even vertex
- a vertex of odd degree is called an odd vertex
- two vertices of
that have the same degree are called regular vertices - if a graph
has the same degree for all its vertices it’s called an r-regular graph
In a graph
First theorem of graph theory
if
is a graph of size then
When summing the degrees of
Degrees in a bipartite graph
Suppose that
Corollary: every graph has an even number of odd vertices
Proof: Let
the number
Degree sequences
A deIf the degrees of a graph
Suppose we’re given a finite sequence
- the degree of any vertice can never be greater than
where is the order of the graph - a graph has an even number of odd vertices
There’s a theorem called Havel-Hakimi which solves the problem above in polynomial time
A non-increasing sequence
where can form a graph only if the sequence
According to this theorem we can create a new sequence based on the one above that is also a graph, we can apply the theorem recursively to test if the original sequence forms a graph
bool graph_from_sequence(vector<int> °rees) {
int sum = 0;
int size = degrees.size();
for (int i = 0; i < size; i += 1) {
sum += degrees[i];
if (degrees[i] >= size || degrees[i] < 0) {
// a vertice can have a maximum degree of n - 1
// also none of the degrees can be negative
return false;
}
}
if (sum == 0) {
// trivial case
return true;
}
sort(degrees.begin(), degrees.end());
// removing d_1
int max_degree = degrees.back();
degrees.pop_back();
size -= 1;
// subtracting 1 from the next d_1 elements
for (int i = 0; i < max_degree; i += 1) {
degrees[size - 1 - i] -= 1;
}
return graph_from_sequence(degrees);
}
Graphs and matrices
A graph can also be described using a matrix, the adjacency matrix of a graph
The incidence matrix of a graph
Useful observations
Let
Proof: assume for a positive integer
The first element of this sum is the number of walks of length