Learn R Programming

ntwk (version 1.0.0)

row_normalised: Normalise a square matrix by dividing elements by the sum of off-diagonal entries row-wise. Note: sets diagonal to zero.

Description

Normalise a square matrix by dividing elements by the sum of off-diagonal entries row-wise. Note: sets diagonal to zero.

Usage

row_normalised(adj, keep_values = FALSE)

Arguments

adj

Adjacency matrix to normalise

keep_values

Whether to keep off-diagonal values or normalise fully (defaults to FALSE).

Value

A matrix based on adj with zero diagonals and off-diagonal elements sum to one.

Examples

Run this code
# NOT RUN {
d <- 5
adj <- matrix(1, d, d)
row_normalised(adj)
# }

Run the code above in your browser using DataLab