bool graph::cmp_val (edge& a, edge& B)

why pass by reference? Should be value or const ref.