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

reverseEdgeDirections

Reverse the edges of a directed graph


Description

Return a new directed graph instance with each edge oriented in the opposite direction relative to the corresponding edge in the input graph.

Usage

reverseEdgeDirections(g)

Arguments

g

A graph subclass that can be coerced to graphAM

Details

WARNING: this doesn't handle edge attributes properly. It is a preliminary implementation and subject to change.

Value

A graphNEL instance

Author(s)

S. Falcon

Examples

g <- graphNEL(nodes=c("a", "b", "c"),
         edgeL=list(a=c("b", "c"), b=character(0), c=character(0)),
         edgemode="directed")

stopifnot(isAdjacent(g, "a", "b"))
stopifnot(!isAdjacent(g, "b", "a"))

grev <- reverseEdgeDirections(g)
stopifnot(!isAdjacent(grev, "a", "b"))
stopifnot(isAdjacent(grev, "b", "a"))

graph

graph: A package to handle graph data structures

v1.68.0
Artistic-2.0
Authors
R. Gentleman, Elizabeth Whalen, W. Huber, S. Falcon
Initial release

We don't support your browser anymore

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