Content deleted Content added
m →Graph traversal algorithms: reworded "entirely distinct subgraph" to the more precise "connected component", with link to connected component (graph theory) |
Altered template type. Add: chapter, title. | Use this tool. Report bugs. | #UCB_Gadget |
||
(45 intermediate revisions by 33 users not shown) | |||
Line 1:
{{redirect-distinguish|Graph search|Facebook Graph Search}}
{{Short description|Computer science algorithm}}
{{refimprove|date=October 2014}}
In [[computer science]], '''graph traversal''' (also known as '''graph search''') refers to the process of visiting (checking and/or updating) each vertex in a [[Graph (discrete mathematics)|graph]]. Such traversals are classified by the order in which the vertices are visited. [[Tree traversal]] is a special case of graph traversal.
Line 27:
* ''Output'': A labeling of the edges in the connected component of ''v'' as discovery edges and back edges.
===Breadth-first search===
{{main|Breadth-first search}}
{{expand section|date=October 2012}}
A breadth-first search (BFS) is another technique for traversing a finite graph. BFS visits the
====Pseudocode====
* ''Input'': A graph ''G'' and a vertex ''v'' of ''G''.
* ''Output'': The closest vertex to ''v'' satisfying some conditions, or null if no such
==Applications==
Line 72:
* serialization/deserialization of a binary tree vs serialization in sorted order (allows the tree to be re-constructed in an efficient manner);
* [[maze generation algorithm]]s;
* [[
* analysis of networks and relationships.
==Graph exploration==
The problem of graph exploration can be seen as a variant of graph traversal. It is an [[Online algorithm|online problem]], meaning that the information about the graph is only revealed during the runtime of the algorithm. A common model is as follows: given a connected graph {{nowrap|1=''G'' = (''V'', ''E'')}} with non-negative edge weights. The algorithm starts at some vertex, and knows all incident outgoing edges and the vertices at the end of these edges—but not more. When a new vertex is visited, then again all incident outgoing edges and the vertices at the end
For general graphs, the best known algorithms for both undirected and directed graphs is a simple [[greedy algorithm]]:
* In the undirected case, the greedy tour is at most {{nowrap|''O''(ln ''n'')}}-times longer than an optimal tour.<ref>{{cite journal|last1=Rosenkrantz|first1=Daniel J.|last2=Stearns|first2=Richard E.|last3=Lewis, II|first3=Philip M.|title=An Analysis of Several Heuristics for the Traveling Salesman Problem|journal=SIAM Journal on Computing|volume=6|issue=3|pages=563–581|doi=10.1137/0206041|year=1977|s2cid=14764079 }}</ref> The best lower bound known for any deterministic online algorithm is
** Unit weight undirected graphs can be explored with a competitive ration of {{nowrap|2 − ''ε''}},<ref>{{cite journal |last1=Miyazaki |first1=Shuichi |last2=Morimoto |first2=Naoyuki |last3=Okabe |first3=Yasuo |title=The Online Graph Exploration Problem on Restricted Graphs |journal=IEICE Transactions on Information and Systems |date=2009 |volume=E92-D |issue=9 |pages=1620–1627 |doi=10.1587/transinf.E92.D.1620|bibcode=2009IEITI..92.1620M |hdl=2433/226939 |s2cid=8355092 |hdl-access=free }}</ref> which is already a tight bound on [[Tadpole graph|Tadpole graphs]].<ref>{{cite journal |last1=Brandt |first1=Sebastian |last2=Foerster |first2=Klaus-Tycho |last3=Maurer |first3=Jonathan |last4=Wattenhofer |first4=Roger |title=Online graph exploration on a restricted graph class: Optimal solutions for tadpole graphs |journal=Theoretical Computer Science |date=November 2020 |volume=839 |pages=176–185 |doi=10.1016/j.tcs.2020.06.007|arxiv=1903.00581 |s2cid=67856035 }}</ref>
* In the directed case, the greedy tour is at most ({{nowrap|''n'' − 1}})-times longer than an optimal tour. This matches the lower bound of {{nowrap|''n'' − 1}}.<ref>{{cite journal|last1=Foerster|first1=Klaus-Tycho|last2=Wattenhofer|first2=Roger|title=Lower and upper competitive bounds for online directed graph exploration|journal=Theoretical Computer Science|date=December 2016|volume=655|pages=15–29|doi=10.1016/j.tcs.2015.11.017|url=https://zenodo.org/record/895821|doi-access=free}}</ref> An analogous competitive lower bound of ''Ω''(''n'') also holds for randomized algorithms that know the coordinates of each node in a geometric embedding. If instead of visiting all nodes just a single "treasure" node has to be found, the competitive bounds are ''Θ''(''n
==Universal
{{expand section|date=December 2016}}
A
==See also==
* [[External memory graph traversal]]
==References==
{{reflist}}
{{Graph traversal algorithms}}
{{Data structures and algorithms}}
[[Category:Graph algorithms]]
[[Category:Articles with example pseudocode]]
[[de:Suchverfahren#Suche in Graphen]]
|