Main Content

traverse (biograph)

(Removed) Traverse biograph object by following adjacent nodes

The function has been removed. Use bfsearch or dfsearch instead.

Syntax

[disc, pred, closed] = traverse(BGObjS)
[...] = traverse(BGObjS, ...'Depth', DepthValue, ...)
[...] = traverse(BGObjS, ...'Directed', DirectedValue, ...)
[...] = traverse(BGObjS, ...'Method', MethodValue, ...)

Arguments

BGObj Biograph object created by biograph (object constructor).
SInteger that indicates the source node in BGObj.
DepthValueInteger that indicates a node in BGObj that specifies the depth of the search. Default is Inf (infinity).
DirectedValueProperty that indicates whether graph represented by an N-by-N adjacency matrix extracted from a biograph object, BGObj is directed or undirected. Enter false for an undirected graph. This results in the upper triangle of the sparse matrix being ignored. Default is true.
MethodValueCharacter vector that specifies the algorithm used to traverse the graph. Choices are:
  • 'BFS' — Breadth-first search. Time complexity is O(N+E), where N and E are number of nodes and edges respectively.

  • 'DFS' — Default algorithm. Depth-first search. Time complexity is O(N+E), where N and E are number of nodes and edges respectively.

Description

Tip

For introductory information on graph theory functions, see Graph Theory Functions.

[disc, pred, closed] = traverse(BGObjS) traverses the directed graph represented by an N-by-N adjacency matrix extracted from a biograph object, BGObj, starting from the node indicated by integer S. In the N-by-N sparse matrix, all nonzero entries indicate the presence of an edge. disc is a vector of node indices in the order in which they are discovered. pred is a vector of predecessor node indices (listed in the order of the node indices) of the resulting spanning tree. closed is a vector of node indices in the order in which they are closed.

[...] = traverse(BGObjS, ...'PropertyName', PropertyValue, ...) calls traverse with optional properties that use property name/property value pairs. You can specify one or more properties in any order. Each PropertyName must be enclosed in single quotes and is case insensitive. These property name/property value pairs are as follows:

[...] = traverse(BGObjS, ...'Depth', DepthValue, ...) specifies the depth of the search. DepthValue is an integer indicating a node in the graph represented by the N-by-N adjacency matrix extracted from a biograph object, BGObj. Default is Inf (infinity).

[...] = traverse(BGObjS, ...'Directed', DirectedValue, ...) indicates whether the graph represented by the N-by-N adjacency matrix extracted from a biograph object, BGObj is directed or undirected. Set DirectedValue to false for an undirected graph. This results in the upper triangle of the sparse matrix being ignored. Default is true.

[...] = traverse(BGObjS, ...'Method', MethodValue, ...) lets you specify the algorithm used to traverse the graph represented by the N-by-N adjacency matrix extracted from a biograph object, BGObj. Choices are:

  • 'BFS' — Breadth-first search. Time complexity is O(N+E), where N and E are number of nodes and edges respectively.

  • 'DFS' — Default algorithm. Depth-first search. Time complexity is O(N+E), where N and E are number of nodes and edges respectively.

References

[1] Sedgewick, R., (2002). Algorithms in C++, Part 5 Graph Algorithms (Addison-Wesley).

[2] Siek, J.G., Lee, L-Q, and Lumsdaine, A. (2002). The Boost Graph Library User Guide and Reference Manual, (Upper Saddle River, NJ:Pearson Education).

Version History

Introduced in R2006b

expand all

R2022b: Removed

The function has been removed. Use bfsearch or dfsearch instead.