WeaklyConnectedComponents

WeaklyConnectedComponents[g]

gives the weakly connected components of the graph g.

WeaklyConnectedComponents[g,{v1,v2,}]

gives the weakly connected components that include at least one of the vertices v1, v2, .

WeaklyConnectedComponents[g,patt]

gives the connected components that include a vertex that matches the pattern patt.

WeaklyConnectedComponents[{vw,},]

uses rules vw to specify the graph g.

Details

  • WeaklyConnectedComponents returns a list of components {c1,c2,}, where each component ci is given as a list of vertices.
  • Vertices u and v are in the same component ci if there is a sequence of edges joining u and v.
  • Components ci are ordered by their length, with the largest component first.
  • WeaklyConnectedComponents works with undirected graphs, directed graphs, multigraphs, and mixed graphs.

Examples

open allclose all

Basic Examples  (1)

Give the weakly connected components of a graph:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Highlight the components:

In[3]:=
Click for copyable input
Out[3]=

Scope  (8)

Applications  (1)

Properties & Relations  (3)

See Also

WeaklyConnectedGraphQ  WeaklyConnectedGraphComponents  ConnectedComponents  ConnectedGraphComponents  ConnectedGraphQ  FindVertexCut

Introduced in 2012
(9.0)
| Updated in 2015
(10.3)