A graph is an edge list: from[k] is tied to to[k]. The rules below
hold for every network function in crimlab.
Arguments
- from, to
Labels of the two ends of each edge: vectors of the same length (zero when
nodesgives every node) with no missing values.- w
NULL, or one positive weight per edge (a tie's strength, such as the number of co-offences).- nodes
NULL, or every node's label once: the node order of the results and the way to include isolated nodes.- dir
TRUEfor a directed graph (fromsends a tie toto).
Value
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").
Details
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
Wasserman, S. and Faust, K. (1994). Social Network Analysis: Methods and Applications. Cambridge University Press. doi:10.1017/CBO9780511815478