A graph is a data structure consisting of vertices and edges connecting the vertices. Graphs can be directed or undirected. Depth-first search (DFS) and breadth-first search (BFS) are algorithms for traversing graphs by exploring neighboring vertices. DFS uses a stack and explores as far as possible along each branch before backtracking, while BFS uses a queue and explores all neighbors at each depth level first before moving to the next level.