A graph is a non-linear data structure that consists of a set of vertices (or nodes) and a set of edges that connect them. Unlike a tree, which has a hierarchical structure, a graph can have any number of connections between nodes, including cycles (where you can return to a starting node by following the edges).