degree_w PDF Print E-mail

This function calculates the degree and strength of a node.

The options are:

  • edgelist, required
  • measure, default=measure=c("degree", "output")
  • self.loops, default=FALSE
  • type, default="out", this means that the out-degree and out-strength is calculated. You can get the in-degree by writing type="in". For undirected networks, this option has no effect.

To calculate, write the following:

degree_w(edgelist)

Example 1: Degree using random data created by rg_w()

## Load tnet
library(tnet) 
## Generate a directed random graph with 100 nodes, 300 edges.
rg <- rg_w(nodes=10, arcs=30, directed=TRUE, seed=1)
## Run the function
degree_w(rg)
      vertex degree output 
 [1,]      1      2     11 
 [2,]      2      2      8 
 [3,]      3      5     30
 [4,]      4      5     32
 [5,]      5      2     10 
 [6,]      6      2      7 
 [7,]      7      4     20 
 [8,]      8      3     15 
 [9,]      9      2     14 
[10,]     10      3     21 

The first column is the vertex id, the second colum is the degree, and the third column is the strength.

Example 2: Sample data

## Load tnet
library(tnet) 
Image## Sample data
sample <- rbind(
c(1,2,4),
c(1,3,2),
c(2,1,4),
c(2,3,4),
c(2,4,1),
c(2,5,2),
c(3,1,2),
c(3,2,4),
c(4,2,1),
c(5,2,2),
c(5,6,1),
c(6,5,1))
## Run the function
degree_w(sample)
     vertex degree output 
[1,]      1      2      6
[2,]      2      4     11
[3,]      3      2      6
[4,]      4      1      1
[5,]      5      2      3
[6,]      6      1      1
 

 

Last Updated ( Friday, 19 June 2009 )