Add an edge from a to b with the given weight. For undirected networks this is symmetric with connect(b, a, weight). Idempotent on the existence of the edge — calling connect twice updates the weight to the most recent value rather than creating a parallel edge.