mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-25 09:37:14 +00:00
deploy
This commit is contained in:
@@ -3688,7 +3688,7 @@
|
||||
<!-- Page content -->
|
||||
<h1 id="93-graph-traversal">9.3 Graph traversal<a class="headerlink" href="#93-graph-traversal" title="Permanent link">¶</a></h1>
|
||||
<p>Trees represent a "one-to-many" relationship, while graphs have a higher degree of freedom and can represent any "many-to-many" relationship. Therefore, we can consider trees as a special case of graphs. Clearly, <strong>tree traversal operations are also a special case of graph traversal operations</strong>.</p>
|
||||
<p>Both graphs and trees require the application of search algorithms to implement traversal operations. Graph traversal can be divided into two types: "Breadth-First Search (BFS)" and "Depth-First Search (DFS)".</p>
|
||||
<p>Both graphs and trees require the application of search algorithms to implement traversal operations. Graph traversal can be divided into two types: <u>Breadth-First Search (BFS)</u> and <u>Depth-First Search (DFS)</u>.</p>
|
||||
<h2 id="931-breadth-first-search">9.3.1 Breadth-first search<a class="headerlink" href="#931-breadth-first-search" title="Permanent link">¶</a></h2>
|
||||
<p><strong>Breadth-first search is a near-to-far traversal method, starting from a certain node, always prioritizing the visit to the nearest vertices and expanding outwards layer by layer</strong>. As shown in Figure 9-9, starting from the top left vertex, first traverse all adjacent vertices of that vertex, then traverse all adjacent vertices of the next vertex, and so on, until all vertices have been visited.</p>
|
||||
<p><a class="glightbox" href="../graph_traversal.assets/graph_bfs.png" data-type="image" data-width="100%" data-height="auto" data-desc-position="bottom"><img alt="Breadth-first traversal of a graph" class="animation-figure" src="../graph_traversal.assets/graph_bfs.png" /></a></p>
|
||||
@@ -4814,7 +4814,7 @@ aria-label="Footer"
|
||||
<div class="md-copyright">
|
||||
|
||||
<div class="md-copyright__highlight">
|
||||
Copyright © 2022-2024 krahets<br>The website content is licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>
|
||||
Copyright © 2024 krahets<br>The website content is licensed under <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user