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

get_jaccard_similarity

Get Jaccard similarity coefficient scores


Description

Get the Jaccard similarity coefficient scores for one or more nodes in a graph.

Usage

get_jaccard_similarity(graph, nodes = NULL, direction = "all", round_to = 3)

Arguments

graph

A graph object of class dgr_graph.

nodes

An optional vector of node IDs to consider for Jaccard similarity scores. If not supplied, then similarity scores will be provided for every pair of nodes in the graph.

direction

Using all (the default), the function will ignore edge direction when determining scores for neighboring nodes. With out and in, edge direction for neighboring nodes will be considered.

round_to

The maximum number of decimal places to retain for the Jaccard similarity coefficient scores. The default value is 3.

Value

A matrix with Jaccard similarity values for each pair of nodes considered.

Examples

# Create a random graph using the
# `add_gnm_graph()` function
graph <-
  create_graph(
    directed = FALSE) %>%
  add_gnm_graph(
    n = 10,
    m = 15,
    set_seed = 23)

# Get the Jaccard similarity
# values for nodes `5`, `6`,
# and `7`
graph %>%
  get_jaccard_similarity(
    nodes = 5:7)

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.