split_igraph: Split an igraph object into aligned graphs by attribute

View source: R/split_igraph.R

split_igraphR Documentation

Split an igraph object into aligned graphs by attribute

Description

Given an igraph object and an edge attribute, this function finds all unique values of the edge attribute in the graph and returns a list of igraph objects on the same vertex set where each element of the list has a graph containing only those edges with specified attributed.

Usage

split_igraph(g, e_attr, strip_vertex_attr = FALSE)

Arguments

g

An igraph object

e_attr

the name of an edge attribute in g

strip_vertex_attr

Whether to remove all vertex attribute from the new graphs

Value

A named list of igraph objects with names corresponding to the values of the edge attributes.

Examples

g <- igraph::sample_gnm(20, 60)
igraph::E(g)$color <-
  sample(c("red", "green"), 60, replace = TRUE)
split_igraph(g, "color")


dpmcsuss/iGraphMatch documentation built on May 22, 2024, 8:52 p.m.