# as.directed

0th

Percentile

##### Convert between directed and undirected graphs

as.directed converts an undirected graph to directed, as.undirected does the opposite, it converts a directed graph to undirected.

Keywords
graphs
##### Usage
as.directed(graph, mode = c("mutual", "arbitrary"))
as.undirected(graph, mode = c("collapse", "each", "mutual"),
edge.attr.comb = getIgraphOpt("edge.attr.comb"))
##### Arguments
graph
The graph to convert.
mode
Character constant, defines the conversion algorithm. For as.directed it can be mutual or arbitrary. For as.undirected it can be each, collapse or mutual
edge.attr.comb
Specifies what to do with edge attributes, if mode="collapse" or mode="mutual". In these cases many edges might be mapped to a single one in the new graph, and their attributes are combined. Please see
##### Details

Conversion algorithms for as.directed: [object Object],[object Object]

Conversion algorithms for as.undirected: [object Object],[object Object],[object Object]

##### Value

• A new graph object.

##### concept

• Directed graph
• Undirected graph

simplify for removing multiple and/or loop edges from a graph.

##### Aliases
• as.directed
• as.undirected
##### Examples
g <- graph.ring(10)
as.directed(g, "mutual")
g2 <- graph.star(10)
as.undirected(g)

# Combining edge attributes
g3 <- graph.ring(10, directed=TRUE, mutual=TRUE)
E(g3)$weight <- seq_len(ecount(g3)) ug3 <- as.undirected(g3) print(ug3, e=TRUE) x11(width=10, height=5) layout(rbind(1:2)) plot( g3, layout=layout.circle, edge.label=E(g3)$weight)
plot(ug3, layout=layout.circle, edge.label=E(ug3)$weight) g4 <- graph(c(1,2, 3,2,3,4,3,4, 5,4,5,4, 6,7, 7,6,7,8,7,8, 8,7,8,9,8,9, 9,8,9,8,9,9, 10,10,10,10)) E(g4)$weight <- seq_len(ecount(g4))
ug4 <- as.undirected(g4, mode="mutual",
edge.attr.comb=list(weight=length))
print(ug4, e=TRUE)
Documentation reproduced from package igraph, version 0.6.5-2, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.