Enum Class ConnectivityType

java.lang.Object
java.lang.Enum<ConnectivityType>
net.algart.matrices.scanning.ConnectivityType
All Implemented Interfaces:
Serializable, Comparable<ConnectivityType>, Constable

public enum ConnectivityType extends Enum<ConnectivityType>

Connectivity kind of connected objects in the matrix. Used by ConnectedObjectScanner and Boundary2DScanner classes. See definition of this term in comments to ConnectedObjectScanner.

This class is immutable and thread-safe: there are no ways to modify settings of the created instance.

Author:
Daniel Alievsky
  • Enum Constant Details

    • STRAIGHT_ONLY

      public static final ConnectivityType STRAIGHT_ONLY
      Straight connectivity. Two unit elements with coordinates i0, i1, ..., in-1 and j0, j1, ..., jn-1 are neighbours and, so, connected with each other if one from the coordinates differs by 1, but all other coordinates are equal:

      ∑ |ikjk|=1

      For 2D matrices, this connectivity kind is also known as "4-connectivity".

    • STRAIGHT_AND_DIAGONAL

      public static final ConnectivityType STRAIGHT_AND_DIAGONAL
      Straight-and-diagonal connectivity. Two unit elements with coordinates i0, i1, ..., in-1 and j0, j1, ..., jn-1 are neighbours and, so, connected with each other if several (at least one) from their coordinates differ by 1 and all other coordinates are equal:

      max (|ikjk|)=1

      For 2D matrices, this connectivity kind is also known as "8-connectivity".

  • Method Details

    • values

      public static ConnectivityType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ConnectivityType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • numberOfNeighbours

      public int numberOfNeighbours(int dimCount)
      Returns the number of neighbours of any matrix element: 2*dimCount for straight connectivity, 3dimCount-1 for straight-and-diagonal connectivity.
      Parameters:
      dimCount - the number of dimensions of the matrix.
      Returns:
      the number of neighbours of any matrix element.
      Throws:
      IllegalArgumentException - if dimCount<=0 or dimCount>Matrix.MAX_DIM_COUNT_FOR_SOME_ALGORITHMS