Introduction to graphs
Search the web for the
[Koenigsberg bridge problem].
In the figure below, it is possible to trace a path with a pencil so
that the pencil never leaves the paper, and each line segment in
the drawing is crossed exactly once:
===>
Is this possible in this next figure?
figure 1:
Consider the following diagrams:
figure 2:
figure 3:
The figure above is a drawing of a graph.
The letters represent nodes (also called vertices)
of the graph. The lines connecting pairs of letters represent
edges.
Graph terminology:
- A graph G = (V,E) is specified by a set of vertices V and a set of edges E. Each edge is specified by a pair of vertices (u,v).
- The neighbors of a vertex v are the vertices w such that (v,w) is an edge (i.e., (v,w)∈ E.
- a path is a sequence of vertices where each consecutive pair is connected by an edge. The path is simple if no vertex is repeated on the path.
- The length of the path is the number of edges on it.
- The distance between two nodes is the length of the shortest path between them.
- a cycle is a path whose start vertex and end vertex are the same. The cycle is simple if the start vertex occurs twice and each other vertex occurs at most once on the path.
- A pair of vertices is connected if there exists a path starting at one and ending at the other. In this case we also say that each vertex in the pair is reachable from the other.
- a connected component of the graph is a collection of vertices reachable from some vertex.
- the graph itself is connected if it has only one connected component (all vertices are reachable from each other).
- the degree of a vertex is the number of edges the vertex is in.
The question about figure 1 is equivalent to the following question:
- Does the graph in figure 3 have a path that uses each edge exactly once?
References