<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>The Comparison of DFS and BFS Methods on 2D Ising Model</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Dmitrii Yu. Kapitan</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Alexey E. Rybin</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Egor V. Vasiliev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Alexander V. Perzhu</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Petr D. Andriuschenko</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Depth-First Search</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Far Eastern Federal University</institution>
          ,
          <addr-line>Vladivostok</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Institute of Applied Mathematics, Far Eastern Branch, Russian Academy of Science</institution>
          ,
          <addr-line>Vladivostok</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2019</year>
      </pub-date>
      <fpage>16</fpage>
      <lpage>19</lpage>
      <abstract>
        <p>We consider Deep-First Search and Breadth-First Search graph traversal algorithms for finding clusters boundaries on 2D Ising model. We implement and compare these algorithms at different cluster density on lattice. It is shown that Breadth-First Search method has a huge advantage at clusters search on the lattice.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        A breadth search was formally proposed by E. F. Moore [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] in the context of a search for a path through the
labyrinth in 1959. Lee [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] independently discovered the same algorithm in the context of PCB conductor layout in
1961.
visited vertices are added to the new set of "advanced" vertices processed in the next step. Initially, only the source
node enters the set of “advanced” vertices, from which the traversal begins.
      </p>
      <p>This algorithm has similar complexity to DFS - O(|V| + |E|).</p>
      <p>The breadth-first search algorithm is similar to the DFS algorithm, with the only difference that nodes are placed
not in the stack, but in the queue. In this case, the principle of FIFO will be applied - Fist In First Out. The algorithm
can be used to find the shortest path between two nodes.</p>
      <p>The effect of the BFS on the example of a cluster search in the lattice model is shown on Figure 3.</p>
    </sec>
    <sec id="sec-2">
      <title>Comparison</title>
      <p>
        The fundamental difference between trees and graphs (which makes a difference in the implementation of DFS /
BFS) is that there are no cycles in the trees. In graph theory, there is a cycle in any graph where you can leave a node
and go through the graph back to that node. Non-directed graphs always contain loops, because you can simply move
between any two neighbors. There is one exception to this rule: a graph without edges [
        <xref ref-type="bibr" rid="ref10 ref11 ref12 ref13 ref14">10-14</xref>
        ]. But this sort of graphs
won’t be discussed in this article.
      </p>
      <p>
        Most BFS algorithms perform an abbreviated DFS before traversing each adjacency list, placing this result in a
queue, which is then bypassed. For this reason, when used in trees, it is twice as slow as DFS. However, the
advantage is that if you are looking for close neighbors, BFS is faster than DFS [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ].
      </p>
      <p>An important factor when choosing an algorithm for implementation on a high-performance hardware is the
simplicity and efficiency of parallelization, to get all the benefits provided by the cluster. The implementation of the
breadth-first search algorithm allows you to simply parallelize the program, with a greater effect than a parallel
algorithm for depth-first search.</p>
      <p>
        The difference between depth-first search and breadth-first search is that (in the case of an undirected graph) the
result of the depth-first search algorithm is a certain route, following which you can go around all the graph vertices
accessible from the initial vertex [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ]. In this way, it is fundamentally different from the breadth-first search, where
many vertices are simultaneously processed, and only one vertex is processed in the depth-first search at each
moment of the algorithm execution.
      </p>
      <p>
        On the other hand, the DFS does not find the shortest paths, but it is applicable in situations where the graph is not
completely known, but is being investigated by some automated device [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ].
      </p>
      <p>To compare these two algorithms, the program was created on the C++. The algorithms were tested on a square
lattice of the two-dimensional Ising model, where temperature is a randomizing factor, i.e., at low temperatures, the
system is completely ordered. To calculate the size of the maximum cluster, the number of spins was set as N =
100x100, 300x300, 500x500, 700x700, 1000x1000, 2000x2000. The spins were clustered by orientation. Calculations
were carried out for one stream in a supercomputer cluster. Several experiments were conducted. In the first
experiment, a low-temperature situation was modeled, with all spins of the system entering the cluster. The second
experiment was conducted near the phase transition temperature   = 2.269, where the maximum cluster of
codirected spins begins to appear, i.e., it is large, but not all spins are included in it. In the third experiment, the lattice is
completely randomized and consists of a set of small clusters of codirectional spins.</p>
    </sec>
    <sec id="sec-3">
      <title>Conclusion</title>
      <p>In this paper, algorithms were considered for finding clustering, the average number of nodes in a cluster, the size
distribution of clusters, and the appearance of an infinite cluster. We considered breadth-first search and depth-first
search traversing algorithms. A program was also written to compare two algorithms within the framework of the
conditions we are interested in. On the basis of the obtained results, it can be concluded that when choosing an
algorithm for searching clusters, one should use a wide search algorithm due to its advantage in execution speed on a
graph and a simpler parallelization implementation, which is of great importance for supercomputer calculations. And
it will help in further studies of ferromagnetic and antiferromagnetic spin models.</p>
    </sec>
    <sec id="sec-4">
      <title>Acknowledgements</title>
      <p>The research was carried out within the state assignment of FASO of Russia No. 075-00400-19-01.</p>
      <p>Computational resources provided by FEFU supercomputer cluster (cluster.dvfu.ru) and Shared Facility Center
"Data Center of FEB RAS" (Khabarovsk, Russia).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Tarasevich</surname>
          </string-name>
          , Yu.Yu.: Percolation: Theory, Applications, Algorithms // Moscow, URSS Publisher.
          <volume>64</volume>
          p. (
          <year>2002</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Tiwari</surname>
            ,
            <given-names>P.:</given-names>
          </string-name>
          <article-title>An efficient parallel algorithm for shifting the root of a depth first spanning tree</article-title>
          . // Journal of Algorithms - Volume
          <volume>7</volume>
          ,
          <string-name>
            <surname>Issue</surname>
          </string-name>
          1 - Pp.
          <fpage>105</fpage>
          -
          <lpage>119</lpage>
          . (
          <year>1986</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Awerbuch</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          :
          <article-title>A new distributed Depth-First-Search algorithm</article-title>
          // Information Processing Letters. - Volume
          <volume>20</volume>
          ,
          <string-name>
            <surname>Issue</surname>
          </string-name>
          3 - Pages 147-
          <fpage>150</fpage>
          (
          <year>1985</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Mohan</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Sharma; Sitharama S. Iyengar; Narasimha K. Mandyam</surname>
          </string-name>
          ,
          <article-title>An efficient distributed depth-first-search algorithm //</article-title>
          <source>Information Processing Letters</source>
          <volume>32</volume>
          .
          <string-name>
            <surname>- Pages</surname>
          </string-name>
          183-
          <fpage>186</fpage>
          (
          <year>1989</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Moore</surname>
            ,
            <given-names>E. F.</given-names>
          </string-name>
          :
          <article-title>The shortest path through a maze //</article-title>
          <source>Proceedings of an International Symposium on the Theory of Switching</source>
          (Cambridge, Massachusetts, 2-5
          <source>April</source>
          <year>1957</year>
          ) - Harvard University Press. - Vol.
          <volume>2</volume>
          . - P.
          <fpage>285</fpage>
          -
          <lpage>292</lpage>
          . - 345 p.
          <article-title>(Annals of the Computation Laboratory</article-title>
          of Harvard University; Vol.
          <volume>30</volume>
          ) (
          <year>1959</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Lee</surname>
            ,
            <given-names>C. Y.</given-names>
          </string-name>
          :
          <article-title>An algorithm for path connection and its applications</article-title>
          .
          <source>IRE Transactions on Electronic Computers, EC10(3)</source>
          , pp.
          <fpage>346</fpage>
          -
          <lpage>365</lpage>
          (
          <year>1961</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Makki</surname>
            ,
            <given-names>S.A.M.:</given-names>
          </string-name>
          <article-title>Efficient distributed breadth-first search algorithm</article-title>
          // Computer Communications (
          <year>1996</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Yunzhou</surname>
          </string-name>
          , Zhu; To-Yat,
          <article-title>Cheung: A new distributed breadth-first-search algorithm // Elsevier</article-title>
          <string-name>
            <surname>B.V.</surname>
          </string-name>
          (
          <year>1987</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Awerbuch</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gallager</surname>
          </string-name>
          , R.: Distributed BFS algorithms // Foundations of Computer Science // 26th Annual Symposium on Foundations of Computer Science (
          <year>1985</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Shimon</surname>
          </string-name>
          , E.: Graph Algorithms. // W. H. Freeman &amp; Co. New York, NY, USA (
          <year>1979</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Levitin</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Introduction to the Design and</article-title>
          Analysis of Algorithms // Addison Wesley,
          <volume>592</volume>
          pages. (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Kocay</surname>
            ,
            <given-names>W.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Kreher</surname>
            ,
            <given-names>D.L.</given-names>
          </string-name>
          :
          <string-name>
            <surname>Graphs</surname>
          </string-name>
          , Algorithms, and Optimization // CRC Press.
          <article-title>(</article-title>
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Richard</surname>
          </string-name>
          , J. Trudeau: Introduction to Graph Theory // Dover Publications Inc.,
          <source>NY</source>
          (
          <year>1993</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Khee Meng Koh</surname>
            ,
            <given-names>F. M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dong</surname>
          </string-name>
          , Dong Fengming, Tay, Eng Guan: Introduction to Graph Theory: Solutions Manual// World Scientific. (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Cui</surname>
          </string-name>
          , Zehan, Chen, Licheng, Chen, Mingyu, Bao, Yungang, Huang, Yongbing, Lv,
          <source>Huiwei: Evaluation and Optimization of Breadth-First Search on NUMA Cluster. // IEEE International Conference on Cluster Computing - CLUSTER 2012 - Pages 438-448</source>
          . (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Youzou</surname>
            <given-names>Miyadera</given-names>
          </string-name>
          , Koushi Anzai, Hiroshi Unno, Takeo Yaku:
          <article-title>Depth-first layout algorithm for trees</article-title>
          // Springer Science &amp; Business Media, (
          <year>2013</year>
          .)
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <surname>Cidon</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          :
          <article-title>Yet another distributed depth-first-search algorithm // Inf</article-title>
          . Process. Lett.
          <volume>26</volume>
          ,
          <issue>6</issue>
          (January) - Pages
          <fpage>301</fpage>
          -
          <lpage>305</lpage>
          . (
          <year>1988</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>