Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
garm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fmriToolkit
garm
Commits
a8ae5c33
Commit
a8ae5c33
authored
Jun 20, 2018
by
Corson N. Areshenkoff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Conduction and fixes
parent
aaa1c9ae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
15 deletions
+34
-15
heatkern-statistics.R
R/heatkern-statistics.R
+14
-4
heatkern.R
R/heatkern.R
+11
-6
heatkern.Rd
man/heatkern.Rd
+9
-5
No files found.
R/heatkern-statistics.R
View file @
a8ae5c33
heatkern.kernel
<-
function
(
x
,
time
=
NULL
){
heatkern.kernel
<-
function
(
x
,
time
=
NULL
,
...
){
if
(
is.null
(
time
)){
stop
(
'Must specify time points'
)
...
...
@@ -8,7 +8,7 @@ heatkern.kernel <- function(x, time = NULL){
}
# Get normalized laplacian
L
<-
laplacian_matrix
(
x
,
normalized
=
T
,
sparse
=
F
)
L
<-
laplacian_matrix
(
x
,
normalized
=
F
,
sparse
=
F
)
# Spectral decomposition
eig
<-
eigen
(
L
)
...
...
@@ -22,13 +22,13 @@ heatkern.kernel <- function(x, time = NULL){
return
(
hk
)
}
heatkern.trace
<-
function
(
x
,
time
=
NULL
){
heatkern.trace
<-
function
(
x
,
time
=
NULL
,
...
){
hk.mat
<-
heatkern.kernel
(
x
,
time
)
hk.trace
<-
apply
(
hk.mat
,
3
,
function
(
i
)
sum
(
diag
(
i
)))
return
(
hk.trace
)
}
heatkern.heatcontent
<-
function
(
x
,
m
=
1
)
{
heatkern.heatcontent
<-
function
(
x
,
m
=
1
,
...
)
{
if
(
!
is.numeric
(
m
)
||
length
(
m
)
!=
1
||
m
%%
1
!=
0
||
m
<=
0
){
stop
(
'm must be an integer >= 1'
)
...
...
@@ -51,3 +51,13 @@ heatkern.heatcontent <- function(x, m = 1) {
}
heatkern.conduction
<-
function
(
x
,
time
=
NULL
,
init
=
NULL
,
...
){
hk.mat
<-
heatkern.kernel
(
x
,
time
)
if
(
!
length
(
init
)
==
dim
(
hk.mat
)[
1
]){
stop
(
'Length of init must match number of vertices'
)
}
init
<-
matrix
(
as.numeric
(
init
),
ncol
=
1
)
return
(
apply
(
hk.mat
,
3
,
function
(
i
)
i
%*%
init
))
}
R/heatkern.R
View file @
a8ae5c33
#' Heat equation on a graph
#'
#' Runs the heat equation on an igraph object and optionally returns several
#' features describing the conduction of heat
along the edges of
the graph.
#' features describing the conduction of heat
throughout
the graph.
#'
#' @param x An igraph object
#' @param stat The type of feature to return. See details.
...
...
@@ -10,20 +10,24 @@
#' the heat equation on a finite graph. Available statistics include
#' \itemize{
#' \item{"kernel": }{Returns the heat kernel (the solution to the heat equation)
#' evaluated at time points given by a
n integer vector \code{time}
}
#' evaluated at time points given by a
vector "time"
}
#' \item{"trace": }{Returns the trace of the heat kernel at time points given
#' by a
n integer vector \code{time}
.}
#' by a
vector "time"
.}
#' \item{"heatcontent": }{Returns the heat content invariant of the graph (Bai, 2007).
#' Requires an integer
\code{m}
giving the maximum coefficient of the polynomial
#' Requires an integer
"m"
giving the maximum coefficient of the polynomial
#' expansion to return.}
#' \item{"conduction": }{Simulates the conduction of heat across the vertices
#' of the graph given a numeric vector "init" of initial temperatures and a
#' vector "t" of time points.}
#' }
#' @return \itemize{
#' \item{"kernel": }{A square matrix with dimension equal to the number of nodes
#' in x. If more than one time point is specified, a 3d array whose third
#' coordinate is time.}
#' \item{"trace": }{A numeric vector with length equa
tion
to the length of
#' \item{"trace": }{A numeric vector with length equa
l
to the length of
#' \code{time}}
#' \item{"heatcontent": }{A numeric vector with length equation to \code{m}}
#' \item{"conduction: "}{A vertices-by-time matrix of vertex temporatures.}
#' }
#' @author Corson N. Areshenkoff \email{areshenk@protonmail.com}
...
...
@@ -37,7 +41,8 @@ heatkern <- function(x, stat = 'kernel', ...){
h
<-
switch
(
method
,
kernel
=
heatkern.kernel
(
x
,
...
),
trace
=
heatkern.trace
(
x
,
...
),
heatcontent
=
heatkern.heatcontent
(
x
,
...
))
heatcontent
=
heatkern.heatcontent
(
x
,
...
),
conduction
=
heatkern.conduction
(
x
,
...
))
return
(
drop
(
h
))
}
man/heatkern.Rd
View file @
a8ae5c33
...
...
@@ -18,26 +18,30 @@ heatkern(x, stat = "kernel", ...)
\item{"kernel": }{A square matrix with dimension equal to the number of nodes
in x. If more than one time point is specified, a 3d array whose third
coordinate is time.}
\item{"trace": }{A numeric vector with length equa
tion
to the length of
\item{"trace": }{A numeric vector with length equa
l
to the length of
\code{time}}
\item{"heatcontent": }{A numeric vector with length equation to \code{m}}
\item{"conduction: "}{A vertices-by-time matrix of vertex temporatures.}
}
}
\description{
Runs the heat equation on an igraph object and optionally returns several
features describing the conduction of heat
along the edges of
the graph.
features describing the conduction of heat
throughout
the graph.
}
\details{
Functions computes several statistics derived from the solution to
the heat equation on a finite graph. Available statistics include
\itemize{
\item{"kernel": }{Returns the heat kernel (the solution to the heat equation)
evaluated at time points given by a
n integer vector \code{time}
}
evaluated at time points given by a
vector "time"
}
\item{"trace": }{Returns the trace of the heat kernel at time points given
by a
n integer vector \code{time}
.}
by a
vector "time"
.}
\item{"heatcontent": }{Returns the heat content invariant of the graph (Bai, 2007).
Requires an integer
\code{m}
giving the maximum coefficient of the polynomial
Requires an integer
"m"
giving the maximum coefficient of the polynomial
expansion to return.}
\item{"conduction": }{Simulates the conduction of heat across the vertices
of the graph given a numeric vector "init" of initial temperatures and a
vector "t" of time points.}
}
}
\author{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment