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.

DetailsDetails

  • 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.

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

Components in a symbolic array:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=

Components in the first level of an array:

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

Label identical elements in a list:

In[1]:=
Click for copyable input
Out[1]=
New in 8 | Last modified in 9
New to Mathematica? Find your learning path »
Have a question? Ask support »