# sample a pair of correlated random graphs from G(n,p)
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')
# print graphMatch object
match
print(match)
show(match)
# print matching correspondence
match$corr_A # matching correspondence in the first graph
match$corr_B # matching correspondence in the second graph
# get nonseed matching correspondence
match[!match$seeds]
# create graphMatch object from a vector
as.graphMatch(sample(10))
# or data.frame
as.graphMatch(data.frame(a = 1:10, b = sample(1000, 10)))
# get corresponding permutation matrix for the match result
match[] # preferred approach
# or equivalently
get_perm_mat(match)
# sizes of two graphs
dim(match)
# number of matched node pairs
length(match)
# reverse the matching correspondence between two graphs
t(match)
rev(match)
Run the code above in your browser using DataLab