Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

transform_to_complement_graph

Create a complement of a graph


Description

Create a complement graph which contains only edges not present in the input graph. It's important to nodes that any edge attributes in the input graph's edges will be lost. Node attributes will be retained, since they are not affected by this transformation.

Usage

transform_to_complement_graph(graph, loops = FALSE)

Arguments

graph

A graph object of class dgr_graph.

loops

An option for whether loops should be generated in the complement graph.

Value

a graph object of class dgr_graph.

Examples

# Create a simple graph
# with a single cycle
graph <-
  create_graph() %>%
  add_cycle(n = 4)

# Get the graph's edge
# data frame
graph %>% get_edge_df()

# Create the complement
# of the graph
graph_c <-
  graph %>%
    transform_to_complement_graph()

# Get the edge data frame
# for the complement graph
graph_c %>% get_edge_df()

DiagrammeR

Graph/Network Visualization

v1.0.6.1
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.