Convert between directed and undirected graphs
as.directed converts an undirected graph to
as.undirected is the opposite, it converts a directed
graph to undirected.
as.directed(graph, mode = "mutual") as.undirected(graph, mode = "collapse")
- The graph to convert.
- Character constant, defines the conversion algorithm. For
as.directedit can be
as.undirectedit can be
collapse. See details below.
Conversion algorithms for
- A new graph object.
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)