Learn R Programming

ppsbm (version 1.0.0)

convertGroupPair: Convert group pair \((q,l)\)

Description

Gives the index in \(1, \ldots, Q^2\) (directed) or \(1, \ldots, Q(Q+1)/2\) (undirected) that corresponds to group pair \((q,l)\). Works also for vectors of indices \(q\) and \(l\).

Usage

convertGroupPair(q, l, Q, directed = TRUE)

Value

Index corresponding to the group pair \((q,l)\)

Arguments

q

Group index \(q\)

l

Group index \(l\)

Q

Total number of groups \(Q\)

directed

Boolean for directed (TRUE) or undirected (FALSE) case

Details

Relations between groups \((q,l)\) are stored in vectors, whose indexes depend on whether the graph is directed or undirected.

Directed case :

  • The \((q,l)\) group pair is converted into the index \((q-1)Q+l\)

Undirected case :

  • The \((q,l)\) group pair with \(q\leq l\) is converted into the index \((2Q-q+2)*(q-1)/2 +l-q+1\)

Examples

Run this code
# Convert the group pair (3,2) into an index, where the total number of groups is 3,
# for directed and undirected graph

q <- 3
l <- 2
Q <- 3

directedIndex <- convertGroupPair(q,l,Q)
undirectedIndex <- convertGroupPair(q,l,Q, FALSE)

Run the code above in your browser using DataLab