Linear Algebra

GraphSignals.degreesFunction
degrees(g, [T=eltype(g)]; dir=:out)

Degree of each vertex. Return a vector which contains the degree of each vertex in graph g.

Arguments

  • g: should be a adjacency matrix, SimpleGraph, SimpleDiGraph (from Graphs) or SimpleWeightedGraph, SimpleWeightedDiGraph (from SimpleWeightedGraphs).
  • T: result element type of degree vector; default is the element type of g (optional).
  • dir: direction of degree; should be :in, :out, or :both (optional).

Examples

julia> using GraphSignals

julia> m = [0 1 1; 1 0 0; 1 0 0];

julia> GraphSignals.degrees(m)
3-element Vector{Int64}:
 2
 1
 1
GraphSignals.degree_matrixFunction
degree_matrix(g, [T=eltype(g)]; dir=:out, squared=false, inverse=false)

Degree matrix of graph g. Return a matrix which contains degrees of each vertex in its diagonal. The values other than diagonal are zeros.

Arguments

  • g: Should be a adjacency matrix, FeaturedGraph, SimpleGraph, SimpleDiGraph (from Graphs) or SimpleWeightedGraph, SimpleWeightedDiGraph (from SimpleWeightedGraphs).
  • T: The element type of result degree vector. The default type is the element type of g.
  • dir::Symbol: The way to calculate degree of a graph g regards its directions. Should be :in, :out, or :both.
  • squared::Bool: To return a squared degree vector or not.
  • inverse::Bool: To return a inverse degree vector or not.

Examples

julia> using GraphSignals

julia> m = [0 1 1; 1 0 0; 1 0 0];

julia> GraphSignals.degree_matrix(m)
3×3 LinearAlgebra.Diagonal{Int64, Vector{Int64}}:
 2  ⋅  ⋅
 ⋅  1  ⋅
 ⋅  ⋅  1
GraphSignals.normalized_adjacency_matrixFunction
normalized_adjacency_matrix(g, [T=float(eltype(g))]; selfloop=false)

Normalized adjacency matrix of graph g, defined as

\[D^{-\frac{1}{2}} \tilde{A} D^{-\frac{1}{2}}\]

where $D$ is degree matrix and $\tilde{A}$ is adjacency matrix w/o self loop from g.

Arguments

  • g: Should be a adjacency matrix, FeaturedGraph, SimpleGraph, SimpleDiGraph (from Graphs) or SimpleWeightedGraph, SimpleWeightedDiGraph (from SimpleWeightedGraphs).
  • T: The element type of result degree vector. The default type is the element type of g.
  • selfloop: Adding self loop to $\tilde{A}$ or not.
Graphs.LinAlg.laplacian_matrixFunction
laplacian_matrix(g, [T=eltype(g)]; dir=:out)

Laplacian matrix of graph g, defined as

\[D - A\]

where $D$ is degree matrix and $A$ is adjacency matrix from g.

Arguments

  • g: Should be a adjacency matrix, FeaturedGraph, SimpleGraph, SimpleDiGraph (from Graphs) or SimpleWeightedGraph, SimpleWeightedDiGraph (from SimpleWeightedGraphs).
  • T: The element type of result degree vector. The default type is the element type of g.
  • dir::Symbol: The way to calculate degree of a graph g regards its directions. Should be :in, :out, or :both.
GraphSignals.normalized_laplacianFunction
normalized_laplacian(g, [T=float(eltype(g))]; dir=:both, selfloop=false)

Normalized Laplacian matrix of graph g, defined as

\[I - D^{-\frac{1}{2}} \tilde{A} D^{-\frac{1}{2}}\]

where $D$ is degree matrix and $\tilde{A}$ is adjacency matrix w/o self loop from g.

Arguments

  • g: Should be a adjacency matrix, FeaturedGraph, SimpleGraph, SimpleDiGraph (from Graphs) or SimpleWeightedGraph, SimpleWeightedDiGraph (from SimpleWeightedGraphs).
  • T: The element type of result degree vector. The default type is the element type of g.
  • dir::Symbol: The way to calculate degree of a graph g regards its directions. Should be :in, :out, or :both.
  • selfloop::Bool: Adding self loop to $\tilde{A}$ or not.
GraphSignals.scaled_laplacianFunction
scaled_laplacian(g, [T=float(eltype(g))])

Scaled Laplacien matrix of graph g, defined as

\[\hat{L} = \frac{2}{\lambda_{max}} \tilde{L} - I\]

where $\tilde{L}$ is the normalized Laplacian matrix.

Arguments

  • g: Should be a adjacency matrix, FeaturedGraph, SimpleGraph, SimpleDiGraph (from Graphs) or SimpleWeightedGraph, SimpleWeightedDiGraph (from SimpleWeightedGraphs).
  • T: The element type of result degree vector. The default type is the element type of g.
GraphSignals.random_walk_laplacianFunction
random_walk_laplacian(g, [T=float(eltype(g))]; dir=:out)

Random walk normalized Laplacian matrix of graph g, defined as

\[I - D^{-1} A\]

where $D$ is degree matrix and $A$ is adjacency matrix from g.

Arguments

  • g: Should be a adjacency matrix, FeaturedGraph, SimpleGraph, SimpleDiGraph (from Graphs) or SimpleWeightedGraph, SimpleWeightedDiGraph (from SimpleWeightedGraphs).
  • T: The element type of result degree vector. The default type is the element type of g.
  • dir::Symbol: The way to calculate degree of a graph g regards its directions. Should be :in, :out, or :both.
GraphSignals.signless_laplacianFunction
signless_laplacian(g, [T=eltype(g)]; dir=:out)

Signless Laplacian matrix of graph g, defined as

\[D + A\]

where $D$ is degree matrix and $A$ is adjacency matrix from g.

Arguments

  • g: Should be a adjacency matrix, FeaturedGraph, SimpleGraph, SimpleDiGraph (from Graphs) or SimpleWeightedGraph, SimpleWeightedDiGraph (from SimpleWeightedGraphs).
  • T: The element type of result degree vector. The default type is the element type of g.
  • dir::Symbol: The way to calculate degree of a graph g regards its directions. Should be :in, :out, or :both.