traverse (biograph)

Traverse biograph object by following adjacent nodes

Syntax

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

Arguments

 `BGObj` Biograph object created by `biograph` (object constructor). `S` Integer that indicates the source node in `BGObj`. `DepthValue` Integer that indicates a node in `BGObj` that specifies the depth of the search. Default is `Inf` (infinity). `DirectedValue` Property 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`. `MethodValue` String 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(BGObj, S)` 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(BGObj, S, ...'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(BGObj, S, ...'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(BGObj, S, ...'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(BGObj, S, ...'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.