dkh.graph.scc
-
Declaration
struct SCCInfo;
-
Declaration
SCCInfo scc(T)(T g);
強連結成分分解
Examples
import std.algorithm, std.typecons; alias E = Tuple!(int, "to"); E[][] g = new E[][5]; g[0] ~= E(1); g[1] ~= E(2); g[2] ~= E(0); g[2] ~= E(3); g[3] ~= E(4); g[4] ~= E(3); auto info = scc(g); assert(info.id[0] == info.id[1] && info.id[1] == info.id[2]); assert(info.id[3] == info.id[4]); assert(info.id[0] < info.id[3]); //idはトポロジカル順 assert(equal(info.group(0).dup.sort!"a<b", [0, 1, 2])); assert(equal(info.group(3).dup.sort!"a<b", [3, 4]));