Examples for 'igraph::is_matching'


Graph matching

Aliases: is_matching is.matching is.maximal.matching is_max_matching maximum.bipartite.matching max_bipartite_match

Keywords:

### ** Examples

g <- graph_from_literal( a-b-c-d-e-f )
m1 <- c("b", "a", "d", "c", "f", "e")   # maximal matching
m2 <- c("b", "a", "d", "c", NA, NA)     # non-maximal matching
m3 <- c("b", "c", "d", "c", NA, NA)     # not a matching
is_matching(g, m1)
[1] TRUE
is_matching(g, m2)
[1] TRUE
is_matching(g, m3)
[1] FALSE
is_max_matching(g, m1)
[1] TRUE
is_max_matching(g, m2)
[1] FALSE
is_max_matching(g, m3)
[1] FALSE
V(g)$type <- c(FALSE,TRUE)
print_all(g, v=TRUE)
IGRAPH 195279a UN-B 6 5 -- 
+ attr: name (v/c), type (v/l)
+ vertex attributes:
|     name  type
| [1]    a FALSE
| [2]    b  TRUE
| [3]    c FALSE
| [4]    d  TRUE
| [5]    e FALSE
| [6]    f  TRUE
+ edges from 195279a (vertex names):
[1] a--b b--c c--d d--e e--f
max_bipartite_match(g)
$matching_size
[1] 3

$matching_weight
[1] 3

$matching
  a   b   c   d   e   f 
"b" "a" "d" "c" "f" "e" 
g2 <- graph_from_literal( a-b-c-d-e-f-g )
V(g2)$type <- rep(c(FALSE,TRUE), length.out=vcount(g2))
print_all(g2, v=TRUE)
IGRAPH 950f455 UN-B 7 6 -- 
+ attr: name (v/c), type (v/l)
+ vertex attributes:
|     name  type
| [1]    a FALSE
| [2]    b  TRUE
| [3]    c FALSE
| [4]    d  TRUE
| [5]    e FALSE
| [6]    f  TRUE
| [7]    g FALSE
+ edges from 950f455 (vertex names):
[1] a--b b--c c--d d--e e--f f--g
max_bipartite_match(g2)
$matching_size
[1] 3

$matching_weight
[1] 3

$matching
  a   b   c   d   e   f   g 
"b" "a" "d" "c" "f" "e"  NA 
#' @keywords graphs

[Package igraph version 1.3.1 Index]