node_by_domain() summarises the values of a numeric attribute over the domain of each node, that is the nodes that it can reach, or that can reach it. By default, it returns the highest value that each node can reach.

For example, in a network of package dependencies, the highest minimum version of R in the output domain of a package is the minimum version of R that the package needs, together with all the packages that it depends upon.

node_by_domain(
  .data,
  attribute,
  statistic = c("max", "min", "mean", "median", "sum"),
  direction = c("out", "in", "all"),
  cutoff = Inf,
  self = TRUE
)

Arguments

.data

A network object of class stocnet, igraph, tbl_graph, network, or similar. Internally any of these will be coerced to an efficient implementation. For more information on possible coercions, see e.g. manynet::as_stocnet().

attribute

Name of a numeric or logical nodal attribute. Where none is named and the network holds only one nodal attribute besides the reserved ones, such as "label" and "mode", that one is used.

statistic

The statistic to summarise the values in each domain with, one of "max" (the default), "min", "mean", "median", or "sum".

direction

Whether to use the output domain of each node, "out" (the default), the nodes that it can reach; the input domain, "in", the nodes that can reach it; or "all", the nodes that it can reach in either direction. This makes no difference in an undirected network.

cutoff

The maximum length of the paths that define the domain. By default Inf, so the domain holds every node that can be reached. A cutoff of 1 gives the neighbourhood of each node.

self

Logical, whether the node itself is part of its own domain. By default TRUE, so that the result for a node never ignores its own value.

Value

A node_measure numeric vector the length of the nodes in the network, providing the scores for each node. If the network is labelled, then the scores will be labelled with the nodes' names.

The object also carries the measure it computed, the range its values can fall within, and whether and how those values were normalized. These are shown as a one-line header when the object is printed. Where a measure offers a choice between several ways of counting the same thing, it also carries the variant it used. All can be retrieved with attr().

Details

The output domain of a node is the set of nodes that it can reach along directed paths, and its input domain is the set of nodes that can reach it (Lin 1976; Wasserman and Faust 1994). The same sets are also called the out-component and the in-component of the node. In an undirected network the two are the same, and are the component of the node.

Missing values of the attribute are left out. A node whose domain holds no values returns NA.

References

On domains

Lin, Nan. 1976. Foundations of Social Research. New York: McGraw-Hill.

Wasserman, Stanley, and Katherine Faust. 1994. "Social Network Analysis: Methods and Applications". Cambridge: Cambridge University Press.

de Nooy, Wouter, Andrej Mrvar, and Vladimir Batagelj. 2018. Exploratory Social Network Analysis with Pajek. 3rd edition. Cambridge: Cambridge University Press. doi:10.1017/9781108565691

Examples

marvel_friends <- to_unsigned(to_layer(fict_marvel, "relationship"), "positive")
node_by_domain(marvel_friends, "Appearances")
#> # Maximum of the output domain [427, 12751]
#> ▁▁▁▁▁▁█ 
#>   Abomination `Ant-Man` Apocalypse Beast `Black Panther` `Black Widow` Blade
#> 1         427     12751      12751 12751           12751         12751 12751
#> # ... and 46 more values from this nodeset. Use `print_all(...)` to print all values.
node_by_domain(marvel_friends, "Appearances", statistic = "mean", cutoff = 1)
#> # Mean of the output domain [427, 12751]
#> ▁▁▁▁▂▄▁▁ 
#>   Abomination `Ant-Man` Apocalypse Beast `Black Panther` `Black Widow` Blade
#> 1         427     3238.      3634. 5905.           5746.         5740.  4774
#> # ... and 46 more values from this nodeset. Use `print_all(...)` to print all values.