as.directed {igraph} | R Documentation |
as.directed
converts an undirected graph to
directed, as.undirected
is the opposite, it converts a directed
graph to undirected.
as.directed(graph, mode = c("mutual", "arbitrary")) as.undirected(graph, mode = c("collapse", "each"))
graph |
The graph to convert. |
mode |
Character constant, defines the conversion algorithm. For
|
Conversion algorithms for as.directed
:
arbitraryThe number of edges in the graph stays the same, an arbitrarily directed edge is created for each undirected edge.
mutualTwo directed edges are created for each undirected edge, one in each direction.
Conversion algorithms for as.undirected
:
eachThe number of edges remains constant, an undirected edge is created for each directed one, this version might create graphs with multiple edges.
collapseOne undirected edge will be created for each pair of vertices which are connected with at least one directed edge, no multiple edges will be created.
A new graph object.
Gabor Csardi csardi@rmki.kfki.hu
simplify
for removing multiple and/or loop edges
from a graph.
g <- graph.ring(10) as.directed(g, "mutual") g2 <- graph.star(10) as.undirected(g)