Learn R Programming

diffusr (version 0.1.4)

heat.diffusion: Graph diffusion using a heat diffusion process on a Laplacian matrix.

Description

An amount of starting heat gets distribution using the Laplacian matrix of a graph. Every iteration (or time interval) t heat streams from the starting nodes into surrounding nodes.

Usage

heat.diffusion(h0, graph, t = 0.5, ...)

# S4 method for numeric,matrix heat.diffusion(h0, graph, t = 0.5, ...)

# S4 method for matrix,matrix heat.diffusion(h0, graph, t = 0.5, ...)

Arguments

h0

an n x p-dimensional numeric non-negative vector/matrix of starting temperatures

graph

an (n x n)-dimensional numeric non-negative adjacence matrix representing the graph

t

time point when heat is measured

...

additional parameters

Value

returns the heat on every node as numeric vector

References

https://en.wikipedia.org/wiki/Laplacian_matrix https://en.wikipedia.org/wiki/Heat_equation

Examples

Run this code
# NOT RUN {
# count of nodes
n <- 5
# starting distribution (has to sum to one)
h0 <- as.vector(rmultinom(1, 1, prob=rep(.2, n)))
# adjacency matrix (either normalized or not)
graph <- matrix(abs(rnorm(n*n)), n, n)
# computation of stationary distribution
ht <- heat.diffusion(h0, graph)
# }

Run the code above in your browser using DataLab