Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 367 Bytes

graph-weighted.md

File metadata and controls

18 lines (14 loc) · 367 Bytes

Weighted graph

Code

struct Graph {
	struct Edge { int to, weight; };
	Graph(int n):edges(n){}
	void addEdge1(int a, int b, int w) { edges[a].push_back(Edge{b, w}); }
	void addEdge2(int a, int b, int w) { addEdge1(a, b, w); addEdge1(b, a, w); }
	int size() const { return (int)edges.size(); }
	vector<vector<Edge>> edges;
};

Problems

Sources