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 |
edge |
When |
edgetype |
edges and weights information are provided by |
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
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)