%*%,graphMatch,ANY-method | R Documentation |
Methods to use graphMatch objects as operators on igraph and matrix-like objects.
## S4 method for signature 'graphMatch,ANY'
x %*% y
## S4 method for signature 'ANY,graphMatch'
x %*% y
## S4 method for signature 'graphMatch,Matrix'
x %*% y
## S4 method for signature 'Matrix,graphMatch'
x %*% y
## S4 method for signature 'graphMatch,igraph'
x %*% y
## S4 method for signature 'igraph,graphMatch'
x %*% y
x |
Either graphMatch object or a matrix-like object |
y |
Either graphMatch object or a matrix-like object |
These methods return an object of the same type as the non-graphMatch object. If m is the match of g1 to g2 (both igraph objects), then m permuted so as to match with g1. Conversely, g1 returns g1 permuted so as to match with g2.
set.seed(123)
cgnp_pair <- sample_correlated_gnp_pair(n = 10, corr = 0.3, p = 0.5)
g1 <- cgnp_pair$graph1
g2 <- cgnp_pair$graph2
# match g1 & g2 using FW methodology with indefinite relaxation
match <- gm(A = g1, B = g2, seeds = 1:3, method = 'indefinite')
# permute the second graph according to the match result: P %*% g2 %*% P^T
match %*% g2 # return an igraph object
# equivalent to the matrix operation
match[] %*% g2[] %*% t(match[])
match %*% g2[] # return a matrix
# equivalent to:
P <- match[]
P %*% g2[] %*% Matrix::t(P)
# the inverse operations are performed via right multiplication
all(g1[] %*% match == t(P) %*% g1[] %*% P)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.