visNetArc
is supposed to visualise a graph object of class
"igraph" via arc diagram in one-dimensional layout. More precisely, it
displays vertices (nodes) along an axis, with edges linked by arcs.
With proper ordering of vertices (e.g. according to communities and
degrees), arc diagram is able to identify clusters and bridges (as
effective as two-dimensional layout). One advantage of using arc
diagram is to allow for easy annotations along vertices.
visNetArc(g, orientation = c("vertical", "horizontal"), newpage = T, ordering = NULL, labels = V(g)$name, vertex.label.color = "black", vertex.label.cex = 1, vertex.color = "transparent", vertex.frame.color = "black", vertex.size = log(degree(g)) + 0.1, vertex.pch = 21, vertex.lwd = 1, edge.color = "grey", edge.width = 1, edge.lty = 1, ...)
invisible
none
# 1) generate a random graph according to the ER model g <- erdos.renyi.game(100, 1/80) # 2) produce the induced subgraph only based on the nodes in query g <- dNetInduce(g, V(g), knn=0) # 3) color nodes according to communities identified via a spin-glass model and simulated annealing com <- spinglass.community(g, spins=4) vgroups <- com$membership palette.name <- visColormap(colormap="rainbow") vcolors <- palette.name(length(com))[vgroups] # 4) size nodes according to degrees vdegrees <- igraph::degree(g) # 5) sort nodes: first by communities and then degrees tmp <- data.frame(ind=1:vcount(g), vgroups, vdegrees) ordering <- tmp[order(vgroups,vdegrees),]$ind # 6) visualise graph using 1-dimensional arc diagram visNetArc(g, ordering=ordering, labels=V(g)$name, vertex.label.color=vcolors, vertex.color=vcolors, vertex.frame.color=vcolors, vertex.size=log(vdegrees)+0.1) # 7) as comparison, also visualise graph on 2-dimensional layout visNet(g, colormap="bwr", layout=layout.kamada.kawai(g), vertex.label=V(g)$name, vertex.color=vcolors, vertex.frame.color=vcolors, vertex.shape="sphere")