Learn R Programming

multigraphr (version 0.2.0)

nsumk: 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)

Value

A matrix with choose(k+n-1,n-1) rows and n columns. Each row comprises non-negative integers summing to k.

Arguments

n

a positive integer.

k

a positive integer.

Author

Termeh Shafie

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\).

See Also

gof_sim

Examples

Run this code
# 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

Run the code above in your browser using DataLab