attribute_seed: Return seeded graph.

Description Usage Arguments Examples

View source: R/attribute_seed.R

Description

Use 'attribute_seed()' to seed network nodes with diffusion points based on given vertex attributes.

Usage

1
attribute_seed(graph, attr_expression)

Arguments

graph

Graph of class 'igraph'

attr_expression

A logical expression defined in terms of the attribute names of graph. only vertices where the expression evaluates to TRUE are kept.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# generate a graph
vertex_meta <- data.frame('name' = c('a','b','c','d'), value = c(1, 5, 10, 3))
edge_list <- data.frame('v1' = c('a', 'a', 'd', 'd'), 'v2' = c('b', 'c', 'a', 'c'))
graph <- igraph::graph_from_data_frame(d = edge_list, vertices = vertex_meta, directed = FALSE)

# examine initial graph
igraph::vertex_attr(graph)

# seed graph by node value
seeded_graph <- attribute_seed(graph = graph, value > 4)

# examine seeded graph
igraph::vertex_attr(seeded_graph)

# there is now a node attribute 'seed', which is equal to 1 for nodes b and c,
# and 0 for nodes a and d.

taylorpourtaheri/nr documentation built on Dec. 23, 2021, 7:49 a.m.