This line doesn't seem to be correct me. Instead, we should update this variable by d.
Also, it would be better to name it cost_per_flow or something like that to avoid confusion.
A test case would be
TEST(MincostflowTest, SameCostPaths) {
mcf_graph<int, int> g(3);
ASSERT_EQ(0, g.add_edge(0, 1, 1, 1));
ASSERT_EQ(1, g.add_edge(1, 2, 1, 0));
ASSERT_EQ(2, g.add_edge(0, 2, 2, 1));
auto expected = std::vector<std::pair<int, int>>{{0, 0}, {3, 3}};
ASSERT_EQ(expected, g.slope(0, 2));
}