Layout the graph using an igraph layout function.
This function only works with the graph was initialised
with an object of class igraph
.
layout_igraph(g, ..., method = igraph::layout_nicely)
g | An object of class |
---|---|
... | Any options to pass to the |
method | An igraph layout function to compute the nodes and edges (source and target) position on the canvas. |
The function runs the method
to obtain the x
and y
coordinates. These are added to the nodes
data.frame (extracted from initial graph) and to the edges
data.frame, as x
and y
nested columns, e.g.:
c(source_x, target_x)
. These x
and y
coordinates
can be used in asp()
(see example).
ig <- igraph::make_ring(100) # use x and y for positioning g2(ig, asp(x, y)) %>% layout_igraph() %>% fig_edge() %>% fig_point(asp(shape = "circle")) %>% axis_hide()