Update graph.m (used weighted average to determine optimal edge).