ConnectedComponents
✖
ConnectedComponents
gives the connected components that include at least one of the vertices v1, v2, … .
gives the connected components that include a vertex that matches the pattern patt.
Details
- ConnectedComponents returns a list of components {c1,c2,…}, where each component ci is given as a list of vertices.
- For an undirected graph, the vertices u and v are in the same component if there is a path from u to v.
- For a directed graph, the vertices u and v are in the same component if there is a directed path from u to v and from v to u.
- For directed graphs, strongly connected components are computed.
- For undirected graphs, the components are ordered by their length, with the largest component first.
- For directed graphs, the components {c1,c2,…} are given in an order such that there are no edges from ci to ci+1, ci+2, etc.
- ConnectedComponents works with undirected graphs, directed graphs, multigraphs, and mixed graphs.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Scope (8)Survey of the scope of standard use cases
ConnectedComponents works with undirected graphs:
https://wolfram.com/xid/0gfp5mgqpcz3-dy6dt4
https://wolfram.com/xid/0gfp5mgqpcz3-c4jban
https://wolfram.com/xid/0gfp5mgqpcz3-5c4td0
https://wolfram.com/xid/0gfp5mgqpcz3-26nv2e
Use rules to specify the graph:
https://wolfram.com/xid/0gfp5mgqpcz3-bndh30
Select connected components that include at least one of the specified vertices:
https://wolfram.com/xid/0gfp5mgqpcz3-1fttv
Use patterns to select a subset of connected components:
https://wolfram.com/xid/0gfp5mgqpcz3-5ts70e
ConnectedComponents works with large graphs:
https://wolfram.com/xid/0gfp5mgqpcz3-y605q8
https://wolfram.com/xid/0gfp5mgqpcz3-9phlln
Applications (4)Sample problems that can be solved with this function
Highlight components with more than one vertex in a graph:
https://wolfram.com/xid/0gfp5mgqpcz3-1yry5
https://wolfram.com/xid/0gfp5mgqpcz3-bvm4qw
A frog in a lily pond is able to jump 1.5 feet to get from one of the 25 lily pads to another. Model the frog's jumping network from the lily leaf density and SpatialGraphDistribution:
https://wolfram.com/xid/0gfp5mgqpcz3-ekfp0
https://wolfram.com/xid/0gfp5mgqpcz3-e2crlz
https://wolfram.com/xid/0gfp5mgqpcz3-kh8x34
Find the largest collection of lily pads the frog can jump between:
https://wolfram.com/xid/0gfp5mgqpcz3-dhcq16
Use simulation to find the sizes of the largest collections of lily pads for similar ponds:
https://wolfram.com/xid/0gfp5mgqpcz3-fhimm1
https://wolfram.com/xid/0gfp5mgqpcz3-h6cf47
Find the number of times the frog would have to swim to visit all lily pads:
https://wolfram.com/xid/0gfp5mgqpcz3-qtlf91
Simulate to get results for similar lily ponds:
https://wolfram.com/xid/0gfp5mgqpcz3-b7d2ny
https://wolfram.com/xid/0gfp5mgqpcz3-nl42v
Find a permutation p such that the matrix A〚p-1,p〛 is block triangular:
https://wolfram.com/xid/0gfp5mgqpcz3-efcke
Connected components of nonzero positions form block submatrices:
https://wolfram.com/xid/0gfp5mgqpcz3-dd1je
https://wolfram.com/xid/0gfp5mgqpcz3-gihtmb
https://wolfram.com/xid/0gfp5mgqpcz3-b874yl
https://wolfram.com/xid/0gfp5mgqpcz3-b2aqba
Properties & Relations (4)Properties of the function, and connections to other functions
Use WeaklyConnectedComponents to get weakly connected components for directed graphs:
https://wolfram.com/xid/0gfp5mgqpcz3-iyo1k
https://wolfram.com/xid/0gfp5mgqpcz3-zc21d
https://wolfram.com/xid/0gfp5mgqpcz3-rko7z4
Use ConnectedGraphQ to test whether a graph is connected:
https://wolfram.com/xid/0gfp5mgqpcz3-er4tad
https://wolfram.com/xid/0gfp5mgqpcz3-g4pd5
A connected graph has exactly one connected component:
https://wolfram.com/xid/0gfp5mgqpcz3-eqa9km
https://wolfram.com/xid/0gfp5mgqpcz3-dv3jo8
https://wolfram.com/xid/0gfp5mgqpcz3-iji1u1
Every graph with vertices and edges has at least components:
https://wolfram.com/xid/0gfp5mgqpcz3-gxujz7
https://wolfram.com/xid/0gfp5mgqpcz3-ihqkuc
Wolfram Research (2010), ConnectedComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectedComponents.html (updated 2015).
Text
Wolfram Research (2010), ConnectedComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectedComponents.html (updated 2015).
Wolfram Research (2010), ConnectedComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/ConnectedComponents.html (updated 2015).
CMS
Wolfram Language. 2010. "ConnectedComponents." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/ConnectedComponents.html.
Wolfram Language. 2010. "ConnectedComponents." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/ConnectedComponents.html.
APA
Wolfram Language. (2010). ConnectedComponents. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConnectedComponents.html
Wolfram Language. (2010). ConnectedComponents. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ConnectedComponents.html
BibTeX
@misc{reference.wolfram_2024_connectedcomponents, author="Wolfram Research", title="{ConnectedComponents}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/ConnectedComponents.html}", note=[Accessed: 10-January-2025
]}
BibLaTeX
@online{reference.wolfram_2024_connectedcomponents, organization={Wolfram Research}, title={ConnectedComponents}, year={2015}, url={https://reference.wolfram.com/language/ref/ConnectedComponents.html}, note=[Accessed: 10-January-2025
]}