Given a specified meta-path and similarity metric(s), compute the meta-path based similarity score between two nodes.

get_similarity(
  x,
  y,
  mp,
  metric = c("pc", "npc", "dwpc", "pathsim"),
  node_list,
  edge_list = NULL,
  neighbor_list = NULL,
  check = TRUE,
  verbose = TRUE
)

Arguments

x

ID of the origin node.

y

ID of the destination node.

mp

Meta-path as a vector of node types (e.g., c("TypeA", "TypeB", "TypeC")).

metric

A vector of permissible similarity metrics (e.g., c("npc", "dwpc")), see defined metrics below:

Path Count

Specify "pc", corresponding to get_pc().

Normalized Path Count

Specify "npc", corresponding to get_npc().

Degree-Weighted Path Count

Specify "dwpc", corresponding to get_dwpc().

PathSim

Specify "pathsim", corresponding to get_pathsim().

node_list

Node list as a data.table which must contain the following columns:

Node

Node IDs (corresponding to either Origin or Destination in the edge list).

NodeType

Node types (corresponding to either OriginType or DestinationType in the edge list).

edge_list

Edge list as a data.table which must contain the following columns:

Origin

IDs of the origin nodes for each edge.

Destination

IDs of the destination nodes for each edge.

OriginType

Types of the origin node for each edge.

DestinationType

Types of the destination node for each edge.

EdgeType

Types of each edge.

neighbor_list

Neighbor reference object constructed by get_neighbor_list().

check

Should type checking be performed? Default is TRUE.

verbose

Should the intermediate calculations be printed to the console?

Value

A list with six elements:

Origin

ID of the origin node provided (i.e., x).

Destination

ID of the destination node provided (i.e., y).

MP

Meta-path provided (i.e., mp).

OriginPaths

Paths following the provided meta-path from the origin node (i.e., x) to all nodes of the same type as the destination node (i.e., y) as a data.table.

DestinationPaths

Paths following the REVERSE of the provided meta-path from the destination node (i.e., y) to all nodes of the same type as the origin node (i.e., x) as a data.table.

Similarity

Computed meta-path based similarity scores by metric as a data.table.

See also

get_neighbor_list() for neighbor reference object construction and get_similarity_function() for similarity metrics.