Traverse biograph object by following adjacent nodes
[
disc
, pred
, closed
] = traverse(BGObj
, S
)
[...] = traverse(BGObj
, S
, ...'Depth', DepthValue
, ...)
[...] = traverse(BGObj
, S
, ...'Directed', DirectedValue
, ...)
[...] = traverse(BGObj
, S
, ...'Method', MethodValue
, ...)
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 | Character vector that specifies the algorithm used to traverse
the graph. Choices are:
|
Tip
For introductory information on graph theory functions, see Graph Theory Functions.
[
traverses the
directed graph represented by an N-by-N adjacency matrix extracted
from a biograph object, disc
, pred
, closed
] = traverse(BGObj
, S
)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(
calls BGObj
, S
, ...'PropertyName
', PropertyValue
, ...)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(
specifies the depth of the search. BGObj
, S
, ...'Depth', DepthValue
, ...)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(
indicates whether the graph
represented by the N-by-N adjacency matrix extracted from a biograph
object, BGObj
, S
, ...'Directed', DirectedValue
, ...)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(
lets you specify the algorithm
used to traverse the graph represented by the N-by-N adjacency matrix
extracted from a biograph object, BGObj
, S
, ...'Method', MethodValue
, ...)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.
[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).
allshortestpaths
| biograph
| conncomp
| graphtraverse
| isdag
| isomorphism
| isspantree
| maxflow
| minspantree
| shortestpath
| topoorder