Pairs naturally represent graph edges as (source, destination) or (weight, node) depending on your needs. Unweighted edges: vector<pair<int, int>> edges; edges.push_back({u, v}); Each pair is an edge from node u to node v.
Weighted edges often use pair<int, int> as (weight, destination) so that sorting gives edges by weight automatically. This is useful in algorithms like Dijkstra or Kruskal. Adjacency lists: vector<vector<pair<int, int>>> adj(n); adj[u].push_back({v, weight}); Each adj[u] contains all edges from u as (destination, weight) pairs.