Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

findPath

Finding paths


Description

Finds one path between two nodes of a graph.

Usage

findPath(amat, st, en, path = c())

Arguments

amat

a square Boolean matrix with dimnames, the adjacency matrix of a graph.

st

an integer, the starting node.

en

an integer, the ending node.

path

a vector of integers, used in recursive calls. At the beginning is NULL. It should not be modified by the user.

Value

a vector of integers, the sequence of nodes of a path, starting from st to en. In some graphs (spanning trees) there is only one path between two nodes.

Note

This function is not intended to be directly called by the user.

Author(s)

Giovanni M. Marchetti, translating the original Python code (see references).

References

Python Softftware Foundation (2003). Python Patterns — Implementing Graphs. http://www.python.org/doc/essays/graphs/.

See Also

Examples

## A (single) path on a spanning tree
findPath(bfsearch(UG(~ a*b*c + b*d + d*e+ e*c))$tree, st=1, en=5)

ggm

Graphical Markov Models with Mixed Graphs

v2.5
GPL-2
Authors
Giovanni M. Marchetti, Mathias Drton, Kayvan Sadeghi
Initial release
2020-02-014

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.