nsumk {multigraphr} | R Documentation |
Finds ordered n-tuples of non-integers summing to k. Only practical for n < 15.
nsumk(n, k)
n |
a positive integer. |
k |
a positive integer. |
Useful for finding all possible degree sequences for a network with n
nodes
and k
/2 number of edges, or for finding all possible
edge multiplicity sequence n
that sum up to k number of edges.
The number of vertex pair sites (or length of edge multiplicity sequence) for
a multigraph with n nodes is given by n(n+1)/2
.
A matrix with choose(k+n-1,n-1)
rows and n
columns.
Each row comprises non-negative integers summing to k
.
Termeh Shafie
# All possible degree sequences for
# a network with 4 nodes and 5 edges
D <- nsumk(4, 10)
# Remove degree sequences with isolated nodes
D <- D[-which(rowSums(D == 0) > 0), ]
# All edge multiplicity sequences/multigraph with 2 nodes and 4 edges
r <- (2*3)/2 # vertex pair sites (or length of edge multiplicity sequences)
mg <- nsumk(r,4) # number of rows give number of possible multigraphs