1
#' @title Generalized Dominance in Graphs
2
#' @description generalized dominance relations. 
3
#'
4
#' @param A Matrix containing attributes or relations, for instance calculated by [indirect_relations].
5
#' @param type A string which is either 'one-mode' (Default) if \code{A} is a regular one-mode network
6
#' or 'two-mode' if \code{A} is a general data matrix. 
7
#' @param map Logical scalar, whether rows can be sorted or not (Default). See Details.
8
#' @param benefit Logical scalar, whether the attributes or relations are benefit or cost variables.
9
#' @details Positional dominance is a generalization of neighborhood-inclusion for 
10
#' arbitrary network data. In the default case, it checks for all pairs \eqn{u,v} if 
11
#' \eqn{A_{ut} \ge A_{vt}} holds for all \eqn{t} if \code{benefit = TRUE} or 
12
#' \eqn{A_{ut} \le A_{vt}} holds for all \eqn{t} if \code{benefit = FALSE}.  
13
#' This form of dominance is referred to as *dominance under total heterogeneity*. 
14
#' If \code{map=TRUE}, the rows of \eqn{A} are sorted decreasingly (\code{benefit = TRUE}) 
15
#' or increasingly (\code{benefit = FALSE}) and then the dominance condition is checked. This second
16
#' form of dominance is referred to as *dominance under total homogeneity*, while the
17
#' first is called *dominance under total heterogeneity*.
18
#' 
19
#' @return Dominance relations as matrix object. An entry `[u,v]` is `1` if u is dominated by v.
20
#' @author David Schoch
21
#' 
22
#' @references Brandes, U., 2016. Network positions. *Methodological Innovations* 9,
23
#' 2059799116630650.
24
#' 
25
#' Schoch, D. and Brandes, U., 2016. Re-conceptualizing centrality in social networks. 
26
#' *European Journal of Applied Mathematics* 27(6), 971-985.
27
#' 
28
#' @seealso [neighborhood_inclusion], [indirect_relations], [exact_rank_prob]
29
#' @examples
30
#' library(igraph)
31
#' 
32
#' g <- graph.empty(n=11,directed = FALSE)
33
#' g <- add_edges(g,c(1,11,2,4,3,5,3,11,4,8,5,9,5,11,6,7,6,8,
34
#'                    6,10,6,11,7,9,7,10,7,11,8,9,8,10,9,10))
35
#' P<-neighborhood_inclusion(g)
36
#' comparable_pairs(P)
37
#' 
38
#' # positional dominance under total heterogeneity
39
#' dist <- indirect_relations(g,type = "dist_sp")
40
#' D <- positional_dominance(dist,map = FALSE,benefit = FALSE) 
41
#' comparable_pairs(D) 
42
#' 
43
#' # positional dominance under total homogeneity
44
#' D_map <- positional_dominance(dist,map = TRUE,benefit = FALSE) 
45
#' comparable_pairs(D_map) #more comparables than D
46
#' 
47
#' @export
48

49
positional_dominance <- function(A, type = "one-mode", map = FALSE, benefit = TRUE) {
50 2
  if (grepl("one", type)) {
51 2
      D <- matdom(A, map, benefit)
52 2
  } else if (grepl("two", type)) {
53
      # should be implemented in C++
54 2
      fct <- function(x, y) all(x <= y) + 0
55 2
      vecfct <- Vectorize(fct)
56 2
      r.rows <- split(A, row(A))
57 2
      D <- outer(r.rows, r.rows, vecfct)
58 2
      diag(D) <- 0
59
  }
60 2
  if(!is.null(rownames(A)) ){
61 0
    rownames(D) <- rownames(A)
62
  }
63 2
  if(!is.null(colnames(A)) ){
64 0
    colnames(D) <- colnames(A)
65
  }
66 2
  return(D)
67
}

Read our documentation on viewing source code .

Loading