Depth First Search

DFS performs depth first search on graph with source and target vectors.
608 Descargas
Actualizado 7 ago 2016

Ver licencia

DFS performs depth first search on graph with source and target vectors.
Syntax:

[searchNodes,iterations] = dfs(source,target,names,startNode)
[searchNodes,iterations] = dfs(source,target,startNode)

Inputs:

source = Vector or cell array containing starting node of each of the edge.
target = Vector or cell array containing ending node of each of the edge.
names = Cell array containing string names of each of the node.
startNode = Initial node in the graph.

Outputs:

path = Cell array containing search path.
iterations = Table containing dfs iteration summary.

Example 01:

s = {'A','A','A','B','B','C'};
t = {'B','C','D','E','F','G'};
[searchNodes,iterations] = dfs(s,t,'A')

Example 02:

s = [1 1 1 2 2 3];
t = [2 3 4 5 6 7];
names = {'A','B','C','D','E','F','G'};
[searchNodes,iterations] = dfs(s,t,names,'A')

Example 03:

s = [1 1 1 2 2 3];
t = [2 3 4 5 6 7];
[searchNodes,iterations] = dfs(s,t,1)

Coded by Ali Asghar Manjotho
Lecturer, CSE-MUET
Email: ali.manjotho.ali@gmail.com

Citar como

Ali Asghar Manjotho (2025). Depth First Search (https://es.mathworks.com/matlabcentral/fileexchange/58585-depth-first-search), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2012b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Categorías
Más información sobre Graph and Network Algorithms en Help Center y MATLAB Answers.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.0.0