Learn R Programming

graphlayouts (version 0.2.0)

graph_manipulate: Manipulate graph

Description

functions to manipulate graphs

Usage

reorder_edges(g, attr, desc = TRUE)

Arguments

g

igraph object

attr

edge attribute name used to sort edges

desc

logical. sort in descending (default) or ascending order

Value

manipulated graphs

Details

reorder_edges() allows to reorder edges according to an attribute so that edges are drawn in the given order.

Examples

Run this code
# NOT RUN {
library(igraph)
library(ggraph)

g <- sample_gnp(10,0.5)
E(g)$attr <- 1:ecount(g)
ggraph(g,layout="stress")+
  geom_edge_link(aes(col=attr))+
  geom_node_point()+
  theme_graph()+
  theme(legend.position="none")

gn <- reorder_edges(g,"attr")
ggraph(gn,layout="stress")+
  geom_edge_link(aes(col=attr))+
  geom_node_point()+
  theme_graph()+
  theme(legend.position="none")

# }

Run the code above in your browser using DataLab