find_paths {rsemmed} | R Documentation

## Shortest paths between node sets

### Description

Find all shortest paths between sets of nodes

### Usage

    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

    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)

[Package rsemmed version 1.4.0 Index]