init_start: Initialization of the start matrix

View source: R/init_start.R

init_startR Documentation

Initialization of the start matrix

Description

Initialize the start matrix for graph matching iteration.

Usage

init_start(start, nns, ns = 0, soft_seeds = NULL, seeds = NULL, ...)

Arguments

start

A matrix, character, or function. A nns-by-nns matrix, start method like "bari", "convex" or "rds", or a function to initialize the start matrix. If a function, it must have at least the arguments nns, ns, and softs_seeds.

nns

An integer. Number of non-seeds.

ns

An integer. Number of seeds.

soft_seeds

A vector, a matrix or a data frame indicating entries of the start matrix that will be initialized at 1 to indicate . See check_seeds.

seeds

A vector, a matrix or a data frame. Indicating hard seeds. These are used for "convex" start but otherwise are ignored.

...

Arguments passed to other start functions. See details in Values section.

Details

When start is a character, there are five options.

  • "bari" initializes at the barycenter.

  • "rds_perm_bari" gives a random linear combination of barycenter and a random permutation matrix, (1-a) B + a P. The argument g controls a with a being sampled as g * runif().

  • "rds" gives a random doubly stochastic matrix. Users can specify a random deviates generator to the distribution argument, and the default is runif. A random matrix with iid entries from distribution and the the Sinkhorn algorithm is applied to produce the output.

  • "rds_from_sim" gives a random doubly stochastic matrix derived from similarity scores. One needs to input a similarity score matrix to the sim argument for this method. The procedure is the same as "rds" but before the Sinkhorn algorithm is applied, the entries of the random matrix are scaled by sim.

  • "convex" returns the doubly stochastic matrix from the last iteration of running the Frank- Wolfe algorithm with convex relaxation initialized at the barycenter. For this method, one needs to input two graphs A and B, as well as seeds if applicable.

Value

init_start returns a nns-by-nns doubly stochastic matrix as the start matrix in the graph matching iteration. If conduct a soft seeding graph matching, returns a nns-by-nns doubly stochastic matrix with 1's corresponding to the soft seeds and values at the other places are derived by different start method.

Examples

ss <- matrix(c(5, 4, 4, 3), nrow = 2)
# initialize start matrix without soft seeds
init_start(start = "bari", nns = 5)
init_start(start = "rds", nns = 3)
init_start(start = "rds_perm_bari", nns = 5)
init_start(start = "rds_from_sim", nns = 3, sim = matrix(runif(9), 3))

# initialize start matrix with soft seeds
init_start(start = "bari", nns = 5, ns = 1, soft_seeds = ss)
init_start(start = "rds", nns = 5, soft_seeds = ss)
init_start(start = "rds_perm_bari", nns = 5, soft_seeds = ss)


# initialize start matrix for convex graph matching
cgnp_pair <- sample_correlated_gnp_pair(n = 10, corr =  0.3, p =  0.5)
g1 <- cgnp_pair$graph1
g2 <- cgnp_pair$graph2
seeds <- 1:10 <= 2
init_start(start = "convex", nns = 8, A = g1, B = g2, seeds = seeds)

# FW graph matching with incorrect seeds to start at convex start
init_start(start = "convex", nns = 8, ns = 2, soft_seeds = ss, A = g1, B = g2, seeds = seeds)



dpmcsuss/iGraphMatch documentation built on Feb. 15, 2024, 3:26 p.m.