nsumk {multigraphr} | R Documentation |
Ordered n-tuples of non-negative integers summing to k
Description
Finds ordered n-tuples of non-integers summing to k. Only practical for n < 15.
Usage
nsumk(n, k)
Arguments
n |
a positive integer. |
k |
a positive integer. |
Details
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
.
Value
A matrix with choose(k+n-1,n-1)
rows and n
columns.
Each row comprises non-negative integers summing to k
.
Author(s)
Termeh Shafie
See Also
Examples
# 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
[Package multigraphr version 0.2.0 Index]