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 = c("mutual", "arbitrary")) as.undirected(graph, mode = c("collapse", "each"))
- 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.
- Directed graph
- Undirected graph
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)