Main Content

Find all paths between two graph nodes

`[___] = allpaths(`

specifies additional options using one or more name-value arguments. You can use any of the
output argument combinations in previous syntaxes. For example, you can specify
`G`

,`s`

,`t`

,`Name,Value`

)`MaxNumPaths`

and a scalar to limit the number of paths returned.

The number of paths in a graph depends heavily on the structure of the graph. For some graph structures, the number of paths can grow exponentially with the number of nodes. For example, a complete graph with 12 nodes given by

`G = graph(ones(12))`

contains nearly 10 million paths between any two of its nodes. Use the`MaxNumPaths`

,`MaxPathLength`

, and`MinPathLength`

name-value pairs to control the output of`allpaths`

in these cases.