Skip to contents

Finds all paths up to length `maxlen` between specified groups of vertices. This function is needed only becaues igraph`s `all_shortest_paths` finds only the shortest, not any path up to a defined length.

Usage

find_all_paths(
    graph,
    start,
    end,
    attr = NULL,
    mode = 'OUT',
    maxlen = 2,
    progress = TRUE
)

Arguments

graph

An igraph graph object.

start

Integer or character vector with the indices or names of one or more start vertices.

end

Integer or character vector with the indices or names of one or more end vertices.

attr

Character: name of the vertex attribute to identify the vertices by. Necessary if `start` and `end` are not igraph vertex ids but for example vertex names or labels.

mode

Character: IN, OUT or ALL. Default is OUT.

maxlen

Integer: maximum length of paths in steps, i.e. if maxlen = 3, then the longest path may consist of 3 edges and 4 nodes.

progress

Logical: show a progress bar.

Value

List of vertex paths, each path is a character or integer vector.

Examples

interactions <- import_omnipath_interactions()
graph <- interaction_graph(interactions)
paths <- find_all_paths(
    graph = graph,
    start = c('EGFR', 'STAT3'),
    end = c('AKT1', 'ULK1'),
    attr = 'name'
)