gsignal {GSD}R Documentation

Graph Object with a Signal

Description

This function constructs an igraph graph object with several vertex and edge attributes.

Usage

gsignal(vertex, edge, edgetype = c("matrix", "list"))

Arguments

vertex

matrix or data.frame containing vertex information. The first two columns are vertex coordinate x, y, and the third column is a signal z on each vertex.

edge

When edgetype="matrix", a square weighted adjacency matrix. This can be a sparse matrix created with Matrix package. When edgetype="list", matrix or data.frame of edge list with three columns. The first two columns are edge lists and the third column is an edge weight.

edgetype

edges and weights information are provided by "matrix" or "list".

Details

This function constructs an igraph graph object with vertex and edge attributes.

Value

an igraph graph object. The vertex attributes are vertex coordinate x, y, and a signal z on each vertex. The edge attribute is weight. These vertex and edge attributes can be identified by names(vertex_attr()) and names(edge_attr()), and are accessible by V(), E(), as_edgelist(), as_adjacency_matrix() or other igraph functions.

See Also

adjmatrix, gplot.

Examples

#### example : composite of two components having different frequencies

## define vertex coordinate
x <- y <- seq(0, 1, length=30)
xy <- expand.grid(x=x, y=y)

## weighted adjacency matrix by Gaussian kernel 
## for connecting vertices within distance 0.04
A <- adjmatrix(xy, method = "dist", 0.04) 

## signal
# high-frequency component
signal1 <- rep(sin(12.5*pi*x - 1.25*pi), 30)

# low-frequency component
signal2 <- rep(sin(5*pi*x - 0.5*pi), 30)

# composite signal
signal0 <- signal1 + signal2

# noisy signal with SNR(signal-to-noise ratio)=5
signal <- signal0 + rnorm(900, 0, sqrt(var(signal0) / 5)) 

# graph with signal
gsig <- gsignal(vertex = cbind(xy, signal), edge = A, edgetype = "matrix")

# vertex and edge attribute
names(vertex_attr(gsig)); names(edge_attr(gsig))

# edge list
# as_edgelist(gsig, name=FALSE)

# weighted adjacency matrix
# as_adjacency_matrix(gsig, attr="weight")

# display a noisy graph signal 
gplot(gsig, size=3)

# display a composite graph signal 
gplot(gsig, signal0, size=3)

# display high-frequency component
gplot(gsig, signal1, size=3)

# display low-frequency component
gplot(gsig, signal2, size=3)

[Package GSD version 1.0.0 Index]