ArrayComponents[array]
gives an array in which all identical elements of array are replaced by an integer index representing the component in which the element lies.
ArrayComponents[array,level]
finds the identical elements at the specified level in array
ArrayComponents[array,level,rules]
uses a rule or a list of rules for specifying the labels.
ArrayComponents
ArrayComponents[array]
gives an array in which all identical elements of array are replaced by an integer index representing the component in which the element lies.
ArrayComponents[array,level]
finds the identical elements at the specified level in array
ArrayComponents[array,level,rules]
uses a rule or a list of rules for specifying the labels.
Details
- ArrayComponents returns a label matrix where identical elements are represented by consecutive non-negative integers.
- Occurrences of zeros or None in array are always labeled with zeros.
- ArrayComponents can be used to canonicalize label matrices.
Examples
open all close allBasic Examples (3)
Components in a symbolic array:
ArrayComponents[(| | | | |
| - | - | - | - |
| 0 | a | a | a |
| 0 | a | a | a |
| 0 | a | a | a |
| b | b | b | b |), 2]//MatrixFormComponents in the first level of an array:
ArrayComponents[(| | | | |
| - | - | - | - |
| 0 | a | a | a |
| 0 | a | a | a |
| 0 | a | a | a |
| b | b | b | b |), 1]Label identical elements in a list:
ArrayComponents[{8, 2.5, 7, 8}]Scope (3)
ArrayComponents works with arbitrarily nested lists of symbols:
ArrayComponents[{{True, False}, x, {10, 10}, {True, x, {False}}}]Label all positive integers with a specific label:
ArrayComponents[(| | | | |
| - | - | - | - |
| 0 | a | a | a |
| 0 | a | a | a |
| 0 | a | a | a |
| 1 | 2 | 3 | 4 |), 2, n_Integer ? Positive -> -1]//MatrixFormUse a specific label for a component:
ArrayComponents[(| | | | |
| - | - | - | - |
| 0 | a | a | a |
| 0 | a | b | c |
| 0 | a | a | d |
| e | e | e | e |), 2, a -> 0]//MatrixFormRelated Guides
Text
Wolfram Research (2010), ArrayComponents, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayComponents.html (updated 2012).
CMS
Wolfram Language. 2010. "ArrayComponents." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/ArrayComponents.html.
APA
Wolfram Language. (2010). ArrayComponents. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ArrayComponents.html
BibTeX
@misc{reference.wolfram_2026_arraycomponents, author="Wolfram Research", title="{ArrayComponents}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/ArrayComponents.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_arraycomponents, organization={Wolfram Research}, title={ArrayComponents}, year={2012}, url={https://reference.wolfram.com/language/ref/ArrayComponents.html}, note=[Accessed: 15-June-2026]}