Functions

T is a numeric type. if there are negative edges, the correctness of the answer is not guaranteed.