convertGroupPair {ppsbm}R Documentation

Convert group pair (q,l)(q,l)

Description

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

Usage

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

Arguments

q

Group index qq

l

Group index ll

Q

Total number of groups QQ

directed

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

Details

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

Directed case :
  • The (q,l)(q,l) group pair is converted into the index (q1)Q+l(q-1)*Q+l

Undirected case :
  • The (q,l)(q,l) group pair with q<=lq<=l is converted into the index (2Qq+2)(q1)/2+lq+1(2*Q-q+2)*(q-1)/2 +l-q+1

Value

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

Examples

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

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

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


[Package ppsbm version 0.2.2 Index]