Table of Contents Author Guidelines Submit a Manuscript
Mathematical Problems in Engineering
Volume 2017, Article ID 8251305, 7 pages
https://doi.org/10.1155/2017/8251305
Research Article

Algorithm for Identification of Infinite Clusters Based on Minimal Finite Automaton

1Faculty of Information Systems and Technologies, University of Donja Gorica, Podgorica, Montenegro
2Faculty of Project and Innovation Management, Educons University, Belgrade, Serbia

Correspondence should be addressed to Biljana Stamatovic; em.ude.gdu@civotamats.anajlib

Received 5 April 2017; Revised 25 August 2017; Accepted 27 September 2017; Published 24 October 2017

Academic Editor: Yakov Strelniker

Copyright © 2017 Biljana Stamatovic and Goran Kilibarda. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

Abstract

We propose a finite automaton based algorithm for identification of infinite clusters in a 2D rectangular lattice with cells. The algorithm counts infinite clusters and finds one path per infinite cluster in a single pass of the finite automaton. The finite automaton is minimal according to the number of states among all the automata that perform such task. The correctness and efficiency of the algorithm are demonstrated on a planar percolation problem. The algorithm has a computational complexity of and could be appropriate for efficient data flow implementation.

1. Introduction

After the publication of Shannon’s paper in 1951 [1], many scientists considered the behavior of systems of finite automata (FAs) in labyrinths, for example, in connected sets of cells of a grid or lattice. An overview of the obtained results is given in [2, 3]. Some problems of finite automaton (FA) traversing labyrinths can be found in [4, 5]. Many results indicate a limited power of FA. But, by introducing a collective of FAs, it was proved that there exists a collective of two FAs which can traverse all planar mosaic finite labyrinths [6]. Also, in [7, 8], the problem of FA recognition of some infinite classes of labyrinths (e.g., digits and letters) is studied.

Recognizing and labeling connected regions in binary images are important problems in image processing, machine vision, porous matter analysis, and many other fields of science. Studying site and bond percolation on any lattice is an important problem in computational physics [912]. Some algorithms from these studies are presented in [1318]. In [1921], polymerizing systems are presented, with branched or cross-linked polymers, which may go through distinct gelation transitions; a formed gel is seen as a two-dimensional lattice-percolation cluster and the authors use a “hull-generating walk” (HGW) algorithm.

The similarity between the papers [1921] and the present paper consists in the fact that here we use a similar algorithm (in fact, HGW algorithm and the algorithm from our paper are in the class of the so-called “maze solving algorithms” [22]). But in contrast to papers [1921], where HGW algorithm is used for generating perimeters of clusters in a 2D random binary grid, we use our algorithm for identifying and counting infinite clusters in such grid. This is a new, purely mathematical approach, in terms of the theory of finite automata, to the problem considered in our paper. It consists in the construction of a minimal finite automaton (FA) which can traverse the border of any cluster on any 2D binary grid and always stops in the planar site percolation model.

The planar site percolation model is represented by a 2D grid of square cells and each cell can exist in two different states, white or black. Any cell is colored black with probability and white with probability . These probabilities are independent for each cell. We use open boundary conditions with boundary cells on the top and on the bottom of the grid in different states, blue and red, respectively. Cells on the left and right boundaries are white.

We construct an initial FA which can traverse the border of any cluster in every planar 2D grid in accordance with the left-hand rule (which is also a kind of a HGW algorithm). The automaton can be launched from any cell of a grid. In any moment, the input of is information about von Neumann neighborhood of the present cell given in the form of a 5-tuple representing the state of the central cell and the states of its four neighbors. In the next moment, depending on its present state and its input, the FA proceeds from the present cell in one of the directions, defined by the output symbols , , , or (denoting the corresponding directions, east, north, west, or south, resp.), and moves into a corresponding neighbor cell or stays at the same place if output symbol is 0 (which means “no move”) and passes into a new state. On the bases of this automaton, we give an algorithm which can be used for finding/identifying and counting infinite clusters in the given grid. Such algorithm is simple to implement and does not need extra memory or stacks. The time complexity of the algorithm is linear and not larger than the time complexity of already existing algorithms. The FA has only four states, including the initial state. We have proved that this is the minimal FA according to the number of states.

The paper is organized as follows. In Section 2, general grid-related definitions and definitions of the FA and its properties are given. In Section 3, the FA-based algorithm for counting connected paths is described and its complexity is proved. The main conclusions and results are summarized in Section 4.

2. Definition

2.1. General Definitions

The planar site percolation model (see Figure 1) is represented by a two-dimensional lattice network (grid) of unit squares (cells) whose centers are in the integer lattice with cells, . The cell position is determined by its center. Each cell can exist in two different states, 0 or 1, where state 0 is usually called “white” and state 1 is usually called “black.” The boundary cells of the simulated grid are in a fixed state, which remains constant throughout the simulation. The boundary cells on the bottom edge of the grid are in state 2, which is called “red,” and the boundary cells on the top edge of the grid are in state 3, which is called “blue.” The boundary cells on the left and right edge of the grid are white. State 4, which is called “orange,” is used for the notation of labeled cells in the grid.

Figure 1: Examples of percolation site models on grid, generated with probability without infinite cluster (a) and generated with probability with infinite cluster (b).

Two different cells and from a grid are adjacent (weakly adjacent) if (). Two black (white) cells and are connected if there exists a sequence of black (white) cells , , such that each pair and are adjacent; such sequence is called a path. Blue-red path is a path whose one end is adjacent to a blue and the other to a red cell. A set of cells is connected if any two cells from the set are connected. A maximum connected set of black cells is called a cluster. The infinite cluster is a cluster that contains a blue-red path.

Similarly, black (white) cells and are weakly connected if there exists a sequence of black (white) cells , , such that each pair and are weakly adjacent. A maximum weakly connected set of white cells is called a hole.

2.2. Definition of the Initial Finite Automaton

Let , , , and be basic Euclidean vectors. Denote by the set . We use the notations , , , and . For a cell in a grid, its neighbors are cells , , , and . Hence, the von Neumann neighborhood is used in this paper (see Figure 2(a)).

Figure 2: Von Neumann neighborhood and enumeration.

Let be the state of the cell and .

Let be a cyclic permutation. For , and , denote by the element , where , where is the set of natural numbers.

By a finite automaton (FA) , we mean a quintuple , where the finite nonempty sets , , and are the input alphabet, the set of states, and the output alphabet of the automaton, respectively; is its output function; and is its state-transition function. If we mark a state as an initial state of , we get an initial automaton (in other words, is a Mealy machine).

Further, we consider the initial FA supposing that , , and . The starting cell of this automaton in a grid is always the lowest right corner cell of the grid. If the output symbol of is , we say that FA proceeds in the direction . If the output symbol is , the FA stops. This way, FA simulates movements (goes around, traverses) through a grid.

An input symbol represents the state of a cell and the states of its von Neumann neighbors, consistent with the enumeration in Figure 2(b). For the input symbol , by we denote the central cell.

The FA starts in state and uses states from set until it finds a boundary cell on the top of the grid (blue one). In this moment, the algorithm increments the counter of infinite clusters and starts labeling cells with an orange color. The algorithm labels a path, until the FA finds a boundary cell on the bottom edge of the grid (red one). After finding the lowest left end of an infinite cluster, the FA proceeds in the (west) direction and it is on a white cell and in state . After that, the algorithm breaks labeling and starts with new counting of infinite clusters and the FA repeats the process of traversing. The algorithm stops when the output of the FA is 0.

The functions and are defined in the following way. Let be a cell and let , , and . Then, for and input , the functions and are defined by and , where (see Figure 3) except for some “starting,” “ending,” or “changing” parts which are given by the following:(i)If , then(a)for or , and ;(b)for , and ;(c)for and , and .(ii)If , then, for , and .

Figure 3: Traversing part of the FA , where before starting labeling.

Notice two properties of the FA :(1)In the initial state, the FA is on the cell that has red cell on the south (). The FA goes in the west direction until it finds the black cell with black cell on the north. If it cannot find it, the FA stops.(2)The meaning of the fact that the FA is on the cell and is in the state is that the FA has arrived on the cell from the direction , (see Figure 3).

The initial automaton and the initial planar site percolation model , where is the cell on the lowest right corner of a grid , create the sequence , where represents the neighborhood of the cell (), , , , .

Let .

Properties of the FA , which will be crucial for the algorithm, are defined by the following theorem.

Theorem 1. A blue-red path exists in the planar site percolation model if and only if there exists a cell such that the sequence , , of the cells in the sequence creates a blue-red path.

Choosing the cyclic permutation in the definition of the FA , we define an orientation. Namely, if the FA comes on the cell from direction , then the right, ahead, left, and behind cell (from the cell ) are , , , and , respectively.

Let be a blue-red path in the grid and be the infinite cluster that encloses path . Let be the lowest right cell in the cluster and be the subset of the infinite hole which is on the right side of the cluster. Right boundary of the cluster , is weakly adjacent to some cell from , is connected and encloses a blue-red path. Notice that .

It is not hard to see that the FA implements “left-hand-on-wall” algorithm ([23]). Starting from the cell , the FA traverses , and the subsequence , for some , of the sequence creates a blue-red path.

If there is not a connected path between red and blue cells in the grid , then, for all cells , the sequence , , will not contain a cell with blue north neighbor. The grid is finite and the FA will stop on the lowest left cell of the grid.

Theorem 2. According to the number of states, the FA is the minimal initial finite automaton.

In the example from Figure 1(b), notice cell . It is in the infinite cluster and it is weakly adjacent by the right infinite hole. Traversing the cluster by the left-hand rule, the FA is four times in the cell (from south, east, north, and west sides). All the visits must be done in different automaton states (input is the same). Otherwise, the FA makes a cycle. Hence, for traversing a border of a cluster, it is necessary to have 4 states.

3. The FA Traversing Algorithm and Its Time Complexity

The algorithm for identification of infinite clusters is based on the FA . To ensure appropriate counting of infinite clusters, the algorithm uses three global variables: count, labeling, and countingCluster. The count counts the number of infinite clusters, labeling is an indicator for labeling cells, and countingCluster is an indicator for the counting of the infinite cluster.

Let be an initial grid, where is a grid and is its lowest right corner. Let be the initial state of the FA . The algorithm is presented as Algorithm 1.

Algorithm 1: FA traversing algorithm.

The FA starts in state and uses states from set until it finds a boundary cell on the top of the grid (blue one). In this moment, the algorithm increments the counter and sets the indicator labeling on true, and the variable countingCluster is set on false. The algorithm labels a path until the FA finds the lowest left cell on the bottom edge of the cluster. After finding the lowest left end of an infinite cluster, the FA goes in state and sets labeling on false and the countingCluster is set on true. After that, the algorithm repeats the process of traversing.

The algorithm stops when the FA outputs 0.

Lemma 3. The algorithm has linear time complexity.

The FA uses von Neumann neighborhood with four neighbors for each grid cell. The automaton is never on the same cell in the same state. Therefore, the FA cannot be more than four times in a particular cell during the execution of the algorithm. The complexity of the algorithm is therefore , where is the number of grid cells.

The algorithm was simulated in NetLogo programming environment. The algorithm was extensively evaluated on various test cases for different sizes of grid and initial density of black cells in initial configuration. In Figure 4, the last states on the initial grids from Figure 1 are shown. In Figure 5, a grid of dimension with probability 0.62, for a black cell, is shown with two infinity clusters, after termination of the FA algorithm. By increasing the probability of black cells, infinite clusters more often appear, as predicted also by the percolation theory. Also, the results of the algorithm are in accordance with site percolation thresholds in the square lattice ([16, 24]).

Figure 4: The FA traversing algorithm for the two examples from Figure 1.
Figure 5: The FA traversing algorithm finds two infinite clusters in a grid of dimensions .

4. Conclusions

A FA-based algorithm for identification of connected paths between top and bottom boundary cells in an arbitrary square grid is proposed. The constructed FA is minimal according to the number of states. The algorithm is based on four essential states: , , , and . Using these states as FA input and assuming von Neumann neighborhood of the grid cells, we can traverse the boundaries of clusters. Because the FA is independent, there is a possibility of putting more than one automaton in different initial cells. Such a parallel approach could further speed up the proposed algorithm. Combining the property of FA, which is never on the same cell in the same state, with labeling, there is a possibility of using the FA in the detection of articulation cells ([25]). Finally, further investigation can be focused on the necessary extensions of the algorithm for 3D grids.

Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

Acknowledgments

This work is supported by the Program of Science-Technological Cooperation between governments of Montenegro and Serbia, 2016–2018.

References

  1. C. E. Shannon, “Presentation of a maze-solving machine, Cybernetics Trans,” in proceedings of the 8th Conf. of the Josiah Macu Jr. Found, pp. 173–180, 1951.
  2. V. B. Kudryavtsev, S. M. Uscumlic, and G. Kilibarda, “The behavior of automata in labyrinths,” Discrete mathematics and applications, vol. 4, pp. 3–28, 1992. View at Google Scholar
  3. G. Kilibarda, V. B. Kudryavtsev, and S. M. Uscumlic, “Collectives of automata in labyrinths,” Discrete Mathematics and Applications, vol. 15, pp. 3–39, 2003. View at Google Scholar
  4. G. Kilibarda, “Universal labyrinth traps for finite sets of automata,” Discrete Mathematics and Applications, vol. 2, pp. 72–79, 1990. View at Google Scholar
  5. G. Kilibarda, “On the complexity of traversing labyrinths by an automaton,” Discrete mathematics and applications, vol. 5, pp. 116–124, 1993. View at Google Scholar
  6. M. Blum and D. Kozen, “On the power of the compass,” in Proceedings of the 19th Annual Symposium on Foundations of Computer Science, pp. 132–142, 1978.
  7. B. Stamatovic, “On recognizing labyrinth with automata,” Discrete Mathematics and Applications, vol. 12, pp. 51–65, 2000. View at Google Scholar
  8. B. Stamatovic, “Automata recognition two-connected labyrinth with finite cycle diameter,” Programming and Computer Software, vol. 36, pp. 149–157, 2010. View at Google Scholar
  9. S. Kirkpatrick, “Percolation and conduction,” Reviews of Modern Physics, vol. 45, no. 4, pp. 574–588, 1973. View at Publisher · View at Google Scholar · View at Scopus
  10. B. I. Shklovskii and A. L. Efros, Electronic Properties of Doped Semiconductors, Springer-Verlag, 1984.
  11. D. Stauffer, Introduction to Percolation Theory, Taylor & Francis, Abingdon, UK, 1992. View at Publisher · View at Google Scholar
  12. A. Bunde and S. Havlin, Eds., Fractals and Disordered Systems, Springer-Verlag, Berlin, Germany, 1996.
  13. J. Hoshen, P. Klymko, and R. Kopelman, “Percolation and cluster distribution. III. Algorithms for the site-bond problem,” Journal of Statistical Physics, vol. 21, no. 5, pp. 583–600, 1979. View at Publisher · View at Google Scholar · View at Scopus
  14. E. Stoll, “A fast cluster counting algorithm for percolation on and off lattices,” Computer Physics Communications, vol. 109, no. 1, pp. 1–5, 1998. View at Publisher · View at Google Scholar · View at Scopus
  15. R. C. Brower, P. Tamayo, and B. York, “A parallel multigrid algorithm for percolation clusters,” Journal of Statistical Physics, vol. 63, no. 1-2, pp. 73–88, 1991. View at Publisher · View at Google Scholar · View at MathSciNet · View at Scopus
  16. M. E. J. Newman and R. M. Ziff, “Efficient Monte Carlo algorithm and high-precision results for percolation,” Physical Review Letters, vol. 85, no. 19, pp. 4104–4107, 2000. View at Publisher · View at Google Scholar · View at Scopus
  17. R. Trobec and B. Stamatovic, “Analysis and classification of flow-carrying backbones in two-dimensional lattices,” Advances in Engineering Software, vol. 103, pp. 38–45, 2017. View at Publisher · View at Google Scholar · View at Scopus
  18. B. Stamatovic and R. Trobec, “Cellular automata labeling of connected components in n-dimensional binary lattices,” The Journal of Supercomputing, vol. 72, no. 11, pp. 4221–4232, 2016. View at Publisher · View at Google Scholar · View at Scopus
  19. R. M. Ziff, P. T. Cummings, and G. Stells, “Generation of percolation cluster perimeters by a random walk,” Journal of Physics A: General Physics, vol. 17, no. 15, article no. 018, pp. 3009–3017, 1984. View at Publisher · View at Google Scholar · View at Scopus
  20. R. M. Ziff, “Hull-generating walks,” Physica D: Nonlinear Phenomena, vol. 38, no. 1-3, pp. 377–383, 1989. View at Publisher · View at Google Scholar · View at Scopus
  21. R. M. Ziff, “Spanning probability in 2D percolation,” Physical Review Letters, vol. 69, no. 18, pp. 2670–2673, 1992. View at Publisher · View at Google Scholar · View at Scopus
  22. H. Fleischner, “Eulerian graphs and related topics,” Annals of Discrete Mathematics, No. 50, Part 1, vol. 2, 1991. View at Google Scholar
  23. T. Y. Kong and A. Rosenfeld, “Digital topology: Introduction and survey,” Computer Vision Graphics and Image Processing, vol. 48, no. 3, pp. 357–393, 1989. View at Publisher · View at Google Scholar · View at Scopus
  24. M. J. Lee, “Pseudo-random-number generators and the square site percolation threshold,” Physical Review E: Statistical, Nonlinear, and Soft Matter Physics, vol. 78, no. 3, Article ID 031131, 2008. View at Publisher · View at Google Scholar · View at Scopus
  25. W.-G. Yin and R. Tao, “Algorithm for finding two-dimensional site percolation backbones,” Physica B: Condensed Matter, vol. 279, no. 1-3, pp. 84–86, 2000. View at Publisher · View at Google Scholar · View at Scopus