Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_common_nbrs

Get all common neighbors between two or more nodes


Description

With two or more nodes, get the set of common neighboring nodes.

Usage

get_common_nbrs(graph, nodes)

Arguments

graph

A graph object of class dgr_graph.

nodes

a vector of node ID values of length at least 2.

Value

a vector of node ID values.

Examples

# Create a directed graph with 5 nodes
graph <-
  create_graph() %>%
  add_path(n = 5)

# Find all common neighbor nodes
# for nodes `1` and `2` (there are no
# common neighbors amongst them)
graph %>%
  get_common_nbrs(
    nodes = c(1, 2))

# Find all common neighbor nodes for
# nodes `1` and `3`
graph %>%
  get_common_nbrs(
    nodes = c(1, 3))

DiagrammeR

Graph/Network Visualization

v1.0.6.1
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.