DPedge {GMPro}R Documentation

The edge-exploited version of DPmatching.

Description

This functions is based on DPmatching. Instead of allowing each vertex in A to connect to one and only one vertex in B, here by introducing parameter d, this function allows for d edges for each vertex in A. More details are in DPmatching.

Usage

DPedge(A = NULL, B = NULL, d, W = NULL)

Arguments

A, B

Two symmetric 0/1 addjacency matrices.

d

A positive integer, indicating the number of candidate matching.

W

A distance matrix between A and B. This argumnet can be null. If W is null, A and B cannot be null.

Value

Dist

The distance matrix between two graphs.

Z

An indicator matrix. Entry Z_{i, j} = 1 indicates a matching between node i in graph A and node j in graph B, 0 otherwise.

Examples

set.seed(2020)
n = 10; q = 1/2; s = 1; p = 1
Parent = matrix(rbinom(n*n, 1, q), nrow = n, ncol = n)
Parent[lower.tri(Parent)] = t(Parent)[lower.tri(Parent)]
diag(Parent) <- 0
### Generate graph A
dA = matrix(rbinom(n*n, 1, s), nrow = n, ncol=n);
dA[lower.tri(dA)] = t(dA)[lower.tri(dA)]
A1 = Parent*dA
tmp = rbinom(n, 1, p)
n.A = length(which(tmp == 1))
indA = sample(1:n, n.A, replace = FALSE)
A = A1[indA, indA]
### Generate graph B
dB = matrix(rbinom(n*n, 1, s), nrow = n, ncol=n);
dB[lower.tri(dB)] = t(dB)[lower.tri(dB)]
B1 = Parent*dB
tmp = rbinom(n, 1, p)
n.B = length(which(tmp == 1))
indB = sample(1:n, n.B, replace = FALSE)
B = B1[indB, indB]
DPmatching(A, B)
W = DPdistance(A, B)
DPedge(A, B, d = 5)

[Package GMPro version 0.1.0 Index]