Learn R Programming

sna (version 2.8)

gt: Transpose an Input Graph

Description

gt returns the graph transpose of its input. For an adjacency matrix, this is the same as using t; however, this function is also applicable to sna edgelists (which cannot be transposed in the usual fashion). Code written using gt instead of t is thus guaranteed to be safe for either form of input.

Usage

gt(x, return.as.edgelist = FALSE)

Value

The transposed graph(s).

Arguments

x

one or more graphs.

return.as.edgelist

logical; should the result be returned in sna edgelist form?

Author

Carter T. Butts buttsc@uci.edu

Details

The transpose of a (di)graph, \(G=(V,E)\), is the graph \(G=(V,E')\) where \(E'=\{(j,i): (i,j) \in E\}\). This is simply the graph formed by reversing the sense of the edges.

See Also

symmetrize, t

Examples

Run this code
#Create a graph....
g<-rgraph(5)
g

#Transpose it
gt(g)
gt(g)==t(g)                  #For adjacency matrices, same as t(g)

#Now, see both versions in edgelist form
as.edgelist.sna(g)
gt(g,return.as.edgelist=TRUE)

Run the code above in your browser using DataLab