Showing 2 of 12 files from the diff.
Other files ignored by Codecov

@@ -1,11 +1,10 @@
Loading
 1 - `#' @title Comparable pairs in a partial ranking` 2 - `#' @description Calculates the fraction of comparable pairs in a partial ranking.` 3 - `#' This fraction is identical to the density of the induced undirected graph of ` 4 - `#' a partial ranking.` 5 - `#' @param P A partial ranking as matrix object calculated with [neighborhood_inclusion]` 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]` 6 4 `#' or [positional_dominance].` 7 5 `#' @return Fraction of comparable pairs in `P`.` 8 6 `#' @author David Schoch` 7 + `#' @seealso [incomparable_pairs]` 9 8 `#' @examples` 10 9 `#' library(igraph)` 11 10 `#' g <- sample_gnp(100,0.1)`
@@ -17,5 +16,26 @@
Loading
 17 16 `#' comparable_pairs(P)` 18 17 `#' @export` 19 18 `comparable_pairs <- function(P) {` 20 - ` round(igraph::graph.density(igraph::graph_from_adjacency_matrix(P, "max")), 8)` 19 + ` 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 + ` igraph::graph.density(igraph::graph.complementer(igraph::graph_from_adjacency_matrix(P, "max")))` 21 41 `}`

@@ -4,9 +4,12 @@
Loading
 4 4 `#' @param n The number of vertices in the graph.` 5 5 `#' @param p The probability of inserting dominating vertices. Equates approximately ` 6 6 `#' to the density of the graph. See Details.` 7 - `#' @details Threshold graphs can be constructed with a binary sequence. For each 0, an isolated ` 7 + `#' @param bseq (0,1)-vector a binary sequence that produces a threshold grah. See details` 8 + `#' @details Either `n` and `p` must be specified or `bseq`.` 9 + `#' Threshold graphs can be constructed with a binary sequence. For each 0, an isolated ` 8 10 `#' vertex is inserted and for each 1, a vertex is inserted that connects to all previously inserted ` 9 11 `#' vertices. The probability of inserting a dominating vertices is controlled with parameter `p`.` 12 + `#' If `bseq` is gicen instead, a threshold graph is constructed from that sequence.` 10 13 `#' An important property of threshold graphs is, that all centrality indices induce the same ranking.` 11 14 `#' @return A threshold graph as igraph object` 12 15 `#' @author David Schoch`
@@ -33,20 +36,31 @@
Loading
 33 36 `#' # centrality scores are perfectly rank correlated` 34 37 `#' cor(degree(g),closeness(g),method = "kendall")` 35 38 `#' @export` 36 - `threshold_graph <- function(n, p) {` 37 - ` if(missing(n)){` 38 - ` stop('argument "n" is missing, with no default')` 39 + `threshold_graph <- function(n, p,bseq) {` 40 + ` if(missing(n) & missing(bseq)){` 41 + ` stop('Either specify both n and p, or bseq ')` 39 42 ` }` 40 - ` if(missing(p)){` 41 - ` stop('argument "p" is missing, with no default')` 43 + ` if(missing(p) & missing(bseq)){` 44 + ` stop('Either specify both n and p, or bseq ')` 42 45 ` }` 43 46 ` ` 44 - ` vschedule <- rep(0, n)` 45 - ` pvals <- stats::runif(n)` 46 - ` ` 47 - ` vschedule[pvals <= p] <- 1` 48 - ` vschedule[n] <- 1` 49 - ` vschedule[1] <- 0` 47 + ` if(!missing(n) & !missing(p)){` 48 + ` vschedule <- rep(0, n)` 49 + ` pvals <- stats::runif(n)` 50 + ` ` 51 + ` vschedule[pvals <= p] <- 1` 52 + ` vschedule[n] <- 1` 53 + ` vschedule[1] <- 0` 54 + ` } else if(!missing(bseq)){` 55 + ` n <- length(bseq)` 56 + ` if(bseq[n]==0){` 57 + ` warning("bseq[n]=0 produces unconnected graphs. using bseq[n]=1 instead")` 58 + ` bseq[n] <- 1` 59 + ` }` 60 + ` vschedule <- bseq` 61 + ` vschedule[1] <- 0` 62 + ` ` 63 + ` }` 50 64 ` dom_vertices <- which(vschedule == 1)` 51 65 ` if (length(dom_vertices) != 1) {` 52 66 ` edgelist <- do.call(rbind, sapply(dom_vertices, function(v) cbind(rep(v, (v - 1)), seq(1, (v - 1)))))`
@@ -55,6 +69,6 @@
Loading
 55 69 ` edgelist <- cbind(rep(n, (n - 1)), seq(1, (n - 1)))` 56 70 ` }` 57 71 ` g <- igraph::graph_from_edgelist(edgelist, directed = FALSE)` 58 - ` ` 72 + ` g\$sequence <- vschedule` 59 73 ` return(g)` 60 74 `}`
Files Coverage
R 60.46%
src 95.25%
Project Totals (39 files) 73.35%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading