1
#' Relative node sizes
2
#'
3
#' Change nodes size depending to their degree (number of relationships)
4
#'
5
#' @inheritParams sg_nodes
6
#' @param initial Initial node size.
7
#'
8
#' @examples
9
#' nodes <- sg_make_nodes(50)
10
#' edges <- sg_make_edges(nodes, 100)
11
#'
12
#' sigmajs() %>%
13
#'   sg_nodes(nodes, id, label) %>% # no need to pass size
14
#'   sg_edges(edges, id, source, target) %>% 
15
#'   sg_relative_size()
16
#' 
17
#' @return A modified version of the \code{sg} object.
18
#'
19
#' @export
20
sg_relative_size <- function(sg, initial = 1) {
21

22 1
	if (missing(sg))
23 1
		stop("missing sg", call. = FALSE)
24

25 1
	if (!inherits(sg, "sigmajs"))
26 1
		stop("sg must be of class sigmajs", call. = FALSE)
27

28 1
	sg$x$relativeSize <- initial
29 1
	sg
30
}

Read our documentation on viewing source code .

Loading