Use this if you are using igraph from R
Minimize edge-crossings in a simple two-row (or column) layout for bipartite graphs.
layout_as_bipartite(graph, types = NULL, hgap = 1, vgap = 1, maxiter = 100) as_bipartite(...)
graph |
The bipartite input graph. It should have a logical
‘ |
types |
A logical vector, the vertex types. If this argument is
|
hgap |
Real scalar, the minimum horizontal gap between vertices in the same layer. |
vgap |
Real scalar, the distance between the two layers. |
maxiter |
Integer scalar, the maximum number of iterations in the crossing minimization stage. 100 is a reasonable default; if you feel that you have too many edge crossings, increase this. |
... |
Arguments to pass to |
The layout is created by first placing the vertices in two rows, according
to their types. Then the positions within the rows are optimized to minimize
edge crossings, using the Sugiyama algorithm (see
layout_with_sugiyama
).
A matrix with two columns and as many rows as the number of vertices in the input graph.
Gabor Csardi csardi.gabor@gmail.com
Other graph layouts:
add_layout_()
,
component_wise()
,
layout_as_star()
,
layout_as_tree()
,
layout_in_circle()
,
layout_nicely()
,
layout_on_grid()
,
layout_on_sphere()
,
layout_randomly()
,
layout_with_dh()
,
layout_with_fr()
,
layout_with_gem()
,
layout_with_graphopt()
,
layout_with_kk()
,
layout_with_lgl()
,
layout_with_mds()
,
layout_with_sugiyama()
,
layout_()
,
merge_coords()
,
norm_coords()
,
normalize()
# Random bipartite graph inc <- matrix(sample(0:1, 50, replace = TRUE, prob=c(2,1)), 10, 5) g <- graph_from_incidence_matrix(inc) plot(g, layout = layout_as_bipartite, vertex.color=c("green","cyan")[V(g)$type+1]) # Two columns g %>% add_layout_(as_bipartite()) %>% plot()