Need to find sub graphs from one big graph using boost::graph
问题 PH -> PH1 PH -> PH2 PH1 -> N1 PH1 -> N2 PH2 -> N3 PH2 -> N4 required output as : sub graph 1 : PH1 -> N1 PH1 -> N2 sub graph 2 : PH2 -> N3 PH2 -> N3 回答1: This is almost trivial using connected_components . The complicating thing is to ignore the PH node. You didn't say whether this node is given or should be detected. I have written some code to try to detect it. Let's Start #include <boost/graph/adjacency_list.hpp> using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost: