repulsion_graph: This function creates a repulsion graph, which is a graph...

View source: R/repulsion.R

repulsion_graphR Documentation

This function creates a repulsion graph, which is a graph where edges between vertices of different classes are emphasized, while edges within the same class are suppressed.

Description

This function creates a repulsion graph, which is a graph where edges between vertices of different classes are emphasized, while edges within the same class are suppressed.

Usage

repulsion_graph(
  W,
  cg,
  method = c("binary", "weighted"),
  threshold = 0,
  norm_fac = 1
)

Arguments

W

The adjacency matrix (weighted or binary) representing the relationships between vertices in the input graph.

cg

The class graph indicating the pairwise relationships among node classes.

method

A character string indicating the method used to create the repulsion graph. Can be either "binary" or "weighted". Default is "binary".

threshold

A numeric value used to filter the adjacency matrix. Edges with weights below this threshold will be ignored. Default is 0.

norm_fac

A numeric value used to normalize the weights in the adjacency matrix when the method is set to "weighted". Default is 1.

Value

A 'neighbor_graph' object representing the repulsion graph.

Examples

# Example with random data
X <- matrix(rnorm(100*100), 100, 100)
labels <- factor(rep(1:5, each=20))
cg <- class_graph(labels)
W <- graph_weights(X, k=10)
R <- repulsion_graph(W, cg, method="weighted")

# Example with iris dataset
data(iris)
X2 <- as.matrix(iris[, 1:4])
labels <- iris[, 5]
cg <- class_graph(labels)
W <- graph_weights(X2, k=6)
R <- repulsion_graph(W, cg, method="weighted")


bbuchsbaum/graphweights documentation built on April 4, 2024, 7:19 p.m.