Skip to contents

Rank vertex-pairs in order of a goodness of matching metric

Usage

best_matches(A, B, match, measure, num = NULL, true_label = NULL)

Arguments

A

A matrix, an igraph object, or a list of either. See check_graph

B

A matrix, an igraph object, or a list of either. See check_graph

match

graphMatch, eg result of call to gm

measure

One of "row_cor", "row_diff", or "row_perm_stat" or a function (see details). Measure for computing goodness of matching.

num

A positive integer or NULL. Number of pairs of best matched vertices needed. NULL indicates all matches.

true_label

the true correspondence (if available).

Value

best_matches returns a data frame with the indices of best matched vertices in \(G_1\) named A_best, the indices of best matched vertices in \(G_2\) named B_best and the values of measure for best matches, where smaller values indicate better matches for all measures. If the true correspondence is available, also returns the precision of top n best matches, for each n <= num.

row_cor takes 1 minus the row correlation value for the corresponding vertex. row_diff takes the row difference value for each corresponding vertex. row_perm_stat uses the row permutation statistics value.

Details

If measure is a function, it should take exactly two matrices or igraph objects as arguments and return a vector of length equal to the number of nonseed nodes in the first object. Smaller values will be taken to indicate better matches.

Examples

cgnp_pair <- sample_correlated_gnp_pair(n = 50, corr =  0.5, p =  0.5)
g1 <- cgnp_pair$graph1
g2 <- cgnp_pair$graph2
seeds <- 1:50 <= 10
match <- gm(g1, g2, seeds, method = "indefinite")

# Application: select best matched seeds from non seeds as new seeds, and do the
# graph matching iteratively to get higher matching accuracy
best_matches(A = g1, B = g2, match = match, measure = "row_perm_stat", num = 5, true_label = 1:50)
#>   A_best B_best measure_value precision
#> 1     11     11     -5.601861         1
#> 2     28     28     -5.287778         1
#> 3     19     19     -4.955661         1
#> 4     34     34     -4.650679         1
#> 5     45     45     -4.650547         1