Last chance! 50% off unlimited learning
Sale ends in
Get the Jaccard similiarity coefficient scores for one or more nodes in a graph.
get_jaccard_similarity(graph, nodes = NULL, direction = "all",
round_to = 3)
a graph object of class
dgr_graph
.
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.
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.
the maximum number of decimal places
to retain for the Jaccard similarity coefficient
scores. The default value is 3
.
a matrix with Jaccard similiarity values for each pair of nodes considered.
# NOT RUN {
# Create a random graph
graph <-
create_random_graph(
10, 22, set_seed = 1)
# Get the Jaccard similarity values for
# nodes `5`, `6`, and `7`
get_jaccard_similarity(graph, 5:7)
#> 5 6 7
#> 5 1.000 0.286 0.500
#> 6 0.286 1.000 0.286
#> 7 0.500 0.286 1.000
# }
Run the code above in your browser using DataLab