Graph Data Structure
A graph is a data structure made of nodes (also called vertices) connected by edges. It models relationships and networks, such as cities connected by roads, people connected on social media, web pages connected by links and computers connected in a network.
Edges can be directed (one-way) or undirected (two-way), and weighted (with a cost such as distance) or unweighted. Graphs are stored as an adjacency list or an adjacency matrix. Common algorithms include breadth-first search (BFS), depth-first search (DFS), Dijkstra's shortest path and topological sorting.