graph - R - igraph hides edges with inverted source and sink vertex -
i need draw graph edges spotted (there labels on), "igraph" package overlap edges has connect 2 vertices, don't share source , sink.
here's example. found layout.circle useful since need fix vertices of graph.
library("igraph") edges <- data.frame(from = c(1, 2, 2, 2, 3, 3), = c(2, 1, 3, 3, 1, 1)) g <- graph.edgelist(as.matrix(edges)) plot(g, layout = layout.circle(g, params = list(root = 1)), edge.label = letters[1:6]) as can see, edges #1 , #2 overlapped. tried use edge.curved option, result identically disappointing:
plot(g, layout = layout.circle(g, params = list(root = 1)), edge.label = letters[1:6], edge.curved = true) now there 2 couples of edges overlapped, , they're unrecognizable. know way me? in advance
the problem seems edge.curved argument uses autocurve.edges function compute edge curvature. apparently doesn't recognize situation. have option of supplying own set of curvatures might try following:
e(g)$label <- letters[1:6] edges_undir <- t(apply(get.edgelist(g), 1, range)) curves <- unlist(lapply( split(e(g)$label, list(edges_undir[,1], edges_undir[,2])), function(x) { seq(0,.5, length.out=length(x))})) plot(g, layout = layout.circle(g, params = list(root = 1)), edge.label=e(g)$label, edge.curved = curves) which gives plot

Comments
Post a Comment