Sei sulla pagina 1di 5

Graph Theory Definitions

A graph is a pair of sets (V, E) where V is a finite set called the set of vertices and E is a set of 2-element
subsets of V , called the set of edges. We view the edges as a set of connections between the nodes. Here is
an example of a graph G:
b
a d
G = (V, E)
e V = {a, b, c, d, e}
E = {{a, b}, {b, c}, {c, d}, {a, d}, {a, e}, {b, e}, {c, e}}
b c
a

Note that this is the same graph as the following (the set of vertices is the same, and the set of edges is the
same):
b
a e

d c
a

In other words, which way you draw the graph is not important, it remains “the same graph”. We will often
draw graphs without naming the vertices, like so, for example:
b

(Do you know what this graph represents?)

Note: We say “one vertex” and “many vertices” (in other words, the plural of “vertex” is “vertices”, and
the singular of “vertices” is “vertex”). We sometimes say node instead of vertex. The plural of “node” is
simply “nodes”.

Note: By definition, mathematical sets are unordered. This means the set {a, b} is the same as the set {b, a},
and so the edges of a graph have no “direction”. If we want a graph in which the edges have a direction
we use a directed graph, also called a digraph. In a digraph, the set of edges E is a set of ordered pairs of
elements of V ; we write an ordered pair as (u, v) (this is different from the ordered pair (v, u)). Here is an
example of a digraph:

1
b
a d
G = (V, E)
e V = {a, b, c, d, e}
E = {(a, b), (a, d), (a, e), (b, e), (c, b), (c, e), (c, d), (d, c)}
b c
a
Note: Sets also ignore repetition of elements (or “don’t allow repetitions”); that is, the set {a, a} is the
same as the set {a}. This has two consequences for the definition of a graph: (1) since edges are defined as
2-element subsets of V , we can have no edges of the form {u, u} = {u} (because this is a 1-element subset
of V ), and (2) we cannot repeat an edge in the graph by listing it twice: by definition, the set of edges
E = {{a, b}, {b, c}, {b, c}} is the same as E = {{a, b}, {b, c}}. This means that our original definition of a
graph does not allow either loops or multiple edges:
b

a a b

a loop multiple edge

Sometimes, however, it is useful to allow loops and/or multiple edges, in which case people simply change
the definition of “graph” (because they would rather change the definition than invent a new word). (Some
people use the term simple graph for a graph without multiple edges, or for a graph with neither loops nor
multiple edges, and you can say loopless to emphasize a graph has no loops; by default, however, the classical
definition of a graph does not allow loops or multiple edges.)
On the other hand, digraphs always allow loops, because (u, u) is a valid ordered pair of vertices (the
definition of “ordered pair” does not require the two coordinates of the ordered pair to be different).

Note: In many places, you will see people write “(u, v)” for the edge of a graph even in an undirected graph.
The notation {u, v} is more correct, but not as common, in fact.

Definition 1 A walk in a graph G = (V, E) is a sequence of the form


(v1 , {v1 , v2 }, v2 , {v2 , v3 }, v3 , . . . , vk , {vk , vk+1 }, vk+1 )
where k ≥ 0, such that {vi , vi+1 } ∈ E for 1 ≤ i ≤ k. The length of the walk is k.
For example, here is a walk in the first graph that we showed:
b
a d

e walk = {b, {b, e}, e, {e, c}, c, {c, b}, b, {b, d}, d}

b c
a

Note: The definition allows walks of length k = 0. Such walks consist of a single vertex: (v1 ).

Note: The definition specifies which edges are used by the walk instead of simply specifying the sequence of
vertices used by the walk “just in case” the graph has multiple edges (e.g., if a different definition of graph
is being used).

Definition 2 A path in a graph G = (V, E) is a walk of length k ≥ 0 in which the vertices v1 , . . . , vk+1 are
all distinct.

2
The above example of a walk is not a path, since it repeats the vertex b. Here is a path:

b
a d

e path = {b, {b, c}, c, {c, e}, e, {e, a}, a, {a, d}, d}

b c
a

Note that if a walk exists between two vertices of a graph, then a path also exists.

Definition 3 A cycle in a graph G = (V, E) is a walk of length k ≥ 1 in which v1 , . . . , vk are distinct and
v1 = vk+1 .
Here is an example:

b
a d

e cycle = {b, {b, c}, c, {c, e}, e, {e, a}, a, {a, d}, d, {d, b}, b}

b c
a

Note: If loops are allowed, a cycle can consist of a single loop.

Definition 4 A graph G = (V, E) is connected if there is a path in G from u to v for every u, v ∈ V .

Definition 5 A connected graph with no cycles is a tree.


emphFact: A tree on n vertices has n − 1 edges, regardless of the “shape” the tree.

Definition 6 A subgraph of a graph G = (V, E) is a graph G′ = (V ′ , E ′ ) such that V ′ ⊆ V , E ′ ⊆ E.

Definition 7 An induced subgraph of a graph G = (V, E) is a subgraph G′ = (V ′ , E ′ ) such that all edges
of E with both endpoints in V are also in E ′ .

b
a d a d a d

G = e G′1 = e G′2 = e

b c b b
a
non-induced subraph induced subgraph

Definition 8 A connected component (or simply a component) of a graph G = (V, E) is a maximal con-
nected induced subgraph of G.
Note: Here “maximal” means that the connected subgraph is not contained in any larger connected subgraph.

Example: The following graph on 6 vertices has four connected components (a triangle and three isolated
vertices):

3
b

G =

Definition 9 A graph G is a forest if each connected component of G is a tree.


Fact: A forest with n vertices and m components (namely, m trees) has n − m edges. (Think of this: a
forest on 100 vertices with two components, one of 47 vertices and the other of 53 vertices, has 46 + 52 =
98 vertices, because a tree on k vertices has k − 1 edges.)

Definition 10 Two vertices of a graph are adjacent if an edge joins them.

Definition 11 A clique of a graph G = (V, E) is a set of vertices V ′ ⊆ V such that all pairs of vertices in
V ′ are adjacent.

Definition 12 An independent set of a graph G = (V, E) is a set of vertices V ′ ⊆ V such that no vertices
in V ′ are adjacent.

Definition 13 A vertex and an edge of a graph are incident if the vertex is an endpoint of that edge. Also
two edges of a graph are incident if they are incident to a common vertex (i.e., share an endpoint). Two
edges are disjoint if they are not incident.

Definition 14 A matching of a graph G = (V, E) is a set of edges E ′ ⊆ E such that all edges in E ′ are
disjoint.
Example (edges in the matching are in bold):
b

Definition 15 A graph G = (V, E) is bipartite if V is the union of two disjoint sets V1 and V2 such that
every edge of G has one endpoint in V1 and one endpoint in V2 (i.e., such that V1 , V2 are independent sets).

Definition 16 A cut of a graph G = (V, E) is a set of edges E ′ ⊆ E such that V is the disjoint union of
two sets of vertices V1 , V2 such that every edge in E ′ has one endpoint in V1 and one endpoint in V2 .
Example (nodes in V1 are black, nodes in V2 are white, cut edges are in bold):
b

Definition 17 A hamiltonian path of a graph G is a path that visits every vertex of G.


Note: Here “visits once” means “visits exactly once”, by definition of a path.

Hamiltonian path example:

4
b

Note: Not every connected graph has a hamiltonian path. For example, most trees don’t have hamiltonian
paths.

Definition 18 A hamiltonian cycle of a graph G is a cycle that visits every vertex of G.

Definition 19 A vertex cover of a graph G = (V, E) is a set of vertices V ′ ⊆ V such that every edge in E
is incident to a vertex in V ′ .
Example (vertex cover nodes are in black):
b

Potrebbero piacerti anche