1
#' @title Comparable pairs in a partial order
2
#' @description  Calculates the fraction of comparable pairs in a partial order.
3
#' @param P A partial order as matrix object, e.g. calculated with [neighborhood_inclusion]
4
#'    or [positional_dominance].
5
#' @return Fraction of comparable pairs in `P`.
6
#' @author David Schoch
7
#' @seealso [incomparable_pairs]
8
#' @examples
9
#' library(igraph)
10
#' g <- sample_gnp(100,0.1)
11
#' P <- neighborhood_inclusion(g)
12
#' comparable_pairs(P)
13
#' # All pairs of vertices are comparable in a threshold graph
14
#' tg <- threshold_graph(100,0.3)
15
#' P <- neighborhood_inclusion(g)
16
#' comparable_pairs(P)
17
#' @export
18
comparable_pairs <- function(P) {
19 1
    igraph::graph.density(igraph::graph_from_adjacency_matrix(P, "max"))
20
}
21

22
#' @title Incomparable pairs in a partial order
23
#' @description  Calculates the fraction of incomparable pairs in a partial order.
24
#' @param P A partial order as matrix object, e.g. calculated with [neighborhood_inclusion]
25
#'    or [positional_dominance].
26
#' @return Fraction of incomparable pairs in `P`.
27
#' @author David Schoch
28
#' @seealso [comparable_pairs]
29
#' @examples
30
#' library(igraph)
31
#' g <- sample_gnp(100,0.1)
32
#' P <- neighborhood_inclusion(g)
33
#' comparable_pairs(P)
34
#' # All pairs of vertices are comparable in a threshold graph
35
#' tg <- threshold_graph(100,0.3)
36
#' P <- neighborhood_inclusion(g)
37
#' comparable_pairs(P)
38
#' @export
39
incomparable_pairs <- function(P) {
40 0
  igraph::graph.density(igraph::graph.complementer(igraph::graph_from_adjacency_matrix(P, "max")))
41
}

Read our documentation on viewing source code .

Loading