optrees (version 1.0)

searchWalk: Finds an open walk in a graph

Description

This function walks a given graph, directed or not, searching for a walk from a starting node to a final node. The searchWalk function uses a deep-first search strategy to returns the first open walk found, regardless it has formed cycles or repeated nodes.

Usage

searchWalk(nodes, arcs, directed = TRUE, start.node = nodes[1], end.node = nodes[length(nodes)], method = NULL)

Arguments

nodes
vector containing the nodes of the graph, identified by a number that goes from $1$ to the order of the graph.
arcs
matrix with the list of arcs of the graph. Each row represents one arc. The first two columns contain the two endpoints of each arc and the third column contains their weights.
directed
logical value indicating whether the graph is directed (TRUE) or not (FALSE).
start.node
number with one node from which a walk start.
end.node
number with final node of the walk.
method
character string specifying which method use to select the arcs that will form the open walk: "min" if the function chooses the minimum weight arcs, "max" if chooses the maximum weight arcs, or NULL if chooses the arcs by their order in the list of arcs.

Value

If searchWalk found an open walk in the graph returns TRUE, a vector with the nodes of the walk and a matrix with the list of arcs of it.