find_paths: Shortest paths between node sets

Description Usage Arguments Details Value See Also Examples

View source: R/find.R

Description

Find all shortest paths between sets of nodes

Usage

1
find_paths(graph, from, to, weights = NULL)

Arguments

graph

The SemMed graph

from

A set of source nodes. from should be of class igraph.vs (a vertex sequence) or an integer vector.

to

A set of destination nodes. to should be of class igraph.vs (a vertex sequence) or an integer vector.

weights

A numeric vector of edge weights. If NULL (the default), all edges have the default weight of 1.

Details

find_paths relies on igraph::all_shortest_paths to find all shortest paths between the nodes in from and to. This function searches for undirected paths.

Because the Semantic MEDLINE graph is a multigraph, there may be multiple paths with the same sequence of nodes. This function collapses these into a single node sequence. The display functions (text_path and plot_path) take care of showing the multiple edges leading to repeated paths.

Value

A list of shortest paths. List items correspond to the node(s) given in from.

See Also

make_edge_weights to tailor the shortest path search

Examples

1
2
3
4
5
data(g_mini)

node_cortisol <- find_nodes(g_mini, names = "Serum cortisol")
node_stress <- find_nodes(g_mini, names = "Chronic Stress")
find_paths(g_mini, from = node_cortisol, to = node_stress)

lmyint/rsemmed documentation built on July 26, 2021, 1:20 a.m.