Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 473 Bytes

diameter.md

File metadata and controls

20 lines (14 loc) · 473 Bytes
title documentation_of
Tree diameter (木の直径)
./diameter.hpp

木の直径を計算.

使用方法

TreeDiameter<long long> tree(N);
for (auto [s, t, w] : edges) tree.add_edge(s, t, w);

// 頂点 r を含む部分木に関して,直径 D とこれをなす頂点列 vs (の一つ)を計算
auto [D, vs] = tree.get_diameter_edges(r);

問題例