Skip to contents

An S4 class for the results of a graph matching function

Usage

graphMatch(corr, nnodes, call = NULL, detail = list())

as.graphMatch(from)

Arguments

corr

data.frame indicating the correspondence between two graphs

nnodes

dimensions of the original two graphs

call

The call to the graph matching function

detail

List with other more detailed information

from

object to convert to graphMatch object

Value

graphMatch object

Details

graphMatch objects are returned by any of the graph matching methods implemented in the iGraphMatch package. These objects are primarily to represent the found correspondence between the two vertex sets. This is represented by a data.frame with two columns indicating the aligned vertex-pairs across the two graphs.

Slots

corr

data.frame indicating the correspondence between two graphs

nnodes

of the original two graphs

call

The call to the graph matching function

Examples

# 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 percolation algorithm with some known node pairs as seeds
match <- gm(A = g1, B = g2, seeds = 1:3, method = 'indefinite')

# graphMatch object
match
#> gm(A = g1, B = g2, seeds = 1:3, method = "indefinite")
#> 
#> Match (10 x 10):
#>    corr_A corr_B
#> 1       1      1
#> 2       2      2
#> 3       3      3
#> 4       4      6
#> 5       5      5
#> 6       6      8
#> 7       7     10
#> 8       8      7
#> 9       9      4
#> 10     10      9

match$corr_A # matching correspondence in the first graph
#>  [1]  1  2  3  4  5  6  7  8  9 10
match$corr_B # matching correspondence in the second graph
#>  [1]  1  2  3  6  5  8 10  7  4  9
match$seeds # vector of logicals indicating seeded nodes
#>  [1]  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

as.data.frame(match)
#>    corr_A corr_B
#> 1       1      1
#> 2       2      2
#> 3       3      3
#> 4       4      6
#> 5       5      5
#> 6       6      8
#> 7       7     10
#> 8       8      7
#> 9       9      4
#> 10     10      9
match[]
#> 10 x 10 sparse Matrix of class "dgCMatrix"
#>                          
#>  [1,] 1 . . . . . . . . .
#>  [2,] . 1 . . . . . . . .
#>  [3,] . . 1 . . . . . . .
#>  [4,] . . . . . 1 . . . .
#>  [5,] . . . . 1 . . . . .
#>  [6,] . . . . . . . 1 . .
#>  [7,] . . . . . . . . . 1
#>  [8,] . . . . . . 1 . . .
#>  [9,] . . . 1 . . . . . .
#> [10,] . . . . . . . . 1 .
dim(match)
#> [1] 10 10
length(match)
#> [1] 10

# matching details unique to the FW methodology with indefinite relaxation
match$iter # number of iterations
#> [1] 2
match$soft # doubly stochastic matrix from the last iteration, can be used to extract soft matching
#> 10 x 10 sparse Matrix of class "dgCMatrix"
#>                          
#>  [1,] 1 . . . . . . . . .
#>  [2,] . 1 . . . . . . . .
#>  [3,] . . 1 . . . . . . .
#>  [4,] . . . . . 1 . . . .
#>  [5,] . . . . 1 . . . . .
#>  [6,] . . . . . . . 1 . .
#>  [7,] . . . . . . . . . 1
#>  [8,] . . . . . . 1 . . .
#>  [9,] . . . 1 . . . . . .
#> [10,] . . . . . . . . 1 .
match$lap_method # method for solving lap
#> [1] "clue"

# create a graphMatch object from a data.frame or matrix
as.graphMatch(data.frame(1:5, 1:5))
#> asMethod(from = object)
#> 
#> Match (5 x 5):
#>   corr_A corr_B
#> 1      1      1
#> 2      2      2
#> 3      3      3
#> 4      4      4
#> 5      5      5
as.graphMatch(1:5)
#> asMethod(from = object)
#> 
#> Match (5 x 5):
#>   corr_A corr_B
#> 1      1      1
#> 2      2      2
#> 3      3      3
#> 4      4      4
#> 5      5      5