Learn R Programming

netdiffuseR (version 1.16.2)

dgr: Indegree, outdegree and degree of the vertices

Description

Computes the requested degree measure for each node in the graph.

Usage

dgr(graph, cmode = "degree", undirected = getOption("diffnet.undirected",
  FALSE), self = getOption("diffnet.self", FALSE),
  valued = getOption("diffnet.valued", FALSE))

Arguments

graph
Any class of accepted graph format (see netdiffuseR-graphs).
cmode
Character scalar. Either "indegree", "outdegree" or "degree".
undirected
Logical scalar. TRUE when the graph is undirected.
self
Logical scalar.. TRUE when self edges should not be considered.
valued
Logical scalar. When FALSE sets every non-zero entry of graph to one.

Value

  • Either a numeric vector of size $n$ with the degree of each node (if graph is a matrix), or a matrix of size $n\times T$.

See Also

Other statistics: cumulative_adopt_count, exposure, hazard_rate, infection, moran, struct_equiv, threshold

Examples

Run this code
# Comparing degree measurements ---------------------------------------------
# Creating an undirected graph
graph <- rgraph_ba()
graph

data.frame(
   In=dgr(graph, "indegree", undirected = FALSE),
   Out=dgr(graph, "outdegree", undirected = FALSE),
   Degree=dgr(graph, "degree", undirected = FALSE)
 )

# Testing on Korean Family Planning (weighted graph) ------------------------
data(kfamilyDiffNet)
d_unvalued <- dgr(kfamilyDiffNet, valued=FALSE)
d_valued   <- dgr(kfamilyDiffNet, valued=TRUE)

any(d_valued!=d_unvalued)

Run the code above in your browser using DataLab