A graph G = (V, E) has a set of vertices or nodes V and a set of edges or arcs or links E, where each edge connects two vertices. We write this mathematically as E ⊆ V X V, where X is called the Cartesian product of two sets. We can write an edge as a pair (v1, v2), where v1 and v2 are each a vertex.
A path is a sequence of vertexes connected by edges: v1, v2, ..., vn where (vi, vi+1) ∈ E. A simple path is a path with no nodes repeated, except possibly at the ends. The length of a path is the number of edges in it. A cycle is a path from a node back to itself; a graph with no cycles is acyclic.
An edge may have a weight or cost associated with it.