getpath: Find a Path in a Mathematical Graph

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Returns a path, if it exists, from the start to the end.

Usage

1
2
3
getpath(x, start, end, ...)
## S3 method for class 'mathgraph'
getpath(x, start, end, ...)

Arguments

x

an object representing a mathematical graph.

start

character string or integer giving the starting node.

end

character string or integer giving the ending node.

...

generic arguments.

Details

getpath is a generic function with methods for "mathgraph", "incidmat" and "adjamat". The default method converts x to class "incidmat".

getpath.adjamat is an implementation of algorithm 2.2 in Chachra, Ghare and Moore (1979) and getpath.incidmat is an implementation of their algorithm 2.3.

The distinction between non-existent paths and paths of length zero may be useful in some situations.

Value

When at least one path exists, a "mathgraph" object containing the edges within the first path found; this may be an empty mathgraph if start and end are equal.
When no path exists, returns NULL.

Note

S Poetry, Patrick J. Burns, Section 13.3

Author(s)

Nick Efthymiou

References

Chachra, V., Ghare, P. M. and Moore, J. M. (1979). Applications of Graph Theory Algorithms. Elvesier North Holland, New York.

See Also

mathgraph, incidmat, adjamat

Examples

1
2
3
getpath(mathgraph(~ 1:3 / 3:5), 1, 5) # returns a path
getpath(mathgraph(~ 1:3 / 3:5), 1, 4) # no path, returns NULL
getpath(mathgraph(~ 1:3 / 3:5), 1, 1) # returns mathgraph()

mathgraph documentation built on May 2, 2019, 11:04 a.m.

Related to getpath in mathgraph...