ntdeg
Degree and strength of each node
ntdeg(from, to, w = NULL, nodes = NULL, dir = FALSE)A graph is an edge list: from[k] is tied to to[k]. The rules below
hold for every network function in crimlab.
Parameters
Section titled “Parameters”from, toLabels of the two ends of each edge: vectors of the same length (zero when
nodesgives every node) with no missing values.wNULL, or one positive weight per edge (a tie’s strength, such as the number of co-offences).nodesNULL, or every node’s label once: the node order of the results and the way to include isolated nodes.dirTRUEfor a directed graph (fromsends a tie toto).
Returns
Section titled “Returns”A data frame with one row per node: node, deg (distinct
neighbours) and wdeg (summed weight); directed, node, in, out,
deg (in + out), win, wout and wdeg. The degrees sum to twice
the number of distinct edges: see proof("ntdeg").
- Nodes are identified by their labels, compared as text (
as.character(); a factor by its labels, unused levels ignored). Results have one row per node, in the order nodes first appear: each edge’sfrom, then itsto, edge by edge. Withnodes, the order is that ofnodes, which must hold every label of the edges once; labels innodesthat no edge names are isolated nodes. - A self-loop (
from[k] == to[k]) is dropped; its node stays. - Repeated edges (the same pair, in either direction when undirected) are merged into one edge whose weight is the sum of their weights (1 each when
wisNULL). Sodegcounts distinct neighbours andwdegcounts edges or their weight. - A missing value in any argument is an error.
References
Section titled “References”Wasserman, S. and Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge University Press. doi:10.1017/CBO9780511815478
Examples
Section titled “Examples”ntdeg(c("a", "a", "b", "a"), c("b", "c", "c", "b"))ntdeg(c("a", "a"), c("b", "c"), nodes = c("c", "b", "a", "z"), dir = TRUE)Generated from the R help page: ntdeg in the R reference.