找出图的出分量和入分量
在此范例中,找出有向图的最大的强连通分量,以及相应的出分量和入分量.
g = [image];bigComponent = Last@SortBy[ConnectedComponents[g], Length];name = {"Largest strongly connected component", "In-component", "Out-component", "Other components"};info = {HighlightGraph[g, Subgraph[g, #], GraphHighlightStyle -> "DehighlightFade"]}& /@ {bigComponent, VertexInComponent[g, bigComponent], VertexOutComponent[g, bigComponent], Complement[VertexList[g], VertexInComponent[g, bigComponent], VertexOutComponent[g, bigComponent]]};ShowPlotSamples[name_, info_] := Framed[Column[{Style[name, 14, Bold, FontFamily -> "Verdana"], Grid[{info}, Spacings -> {1, 0}]}, Alignment -> Center], RoundingRadius -> 9, FrameStyle -> None, Background -> GrayLevel@0.90];Column[MapThread[ShowPlotSamples, {name, info}]]