Graph Layout
1
0
Entering edit mode
@kaustubh-patil-1544
Last seen 10.2 years ago
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/bioconductor/attachments/20060125/ fce12440/attachment.pl
• 794 views
ADD COMMENT
0
Entering edit mode
Li Long ▴ 120
@li-long-1469
Last seen 10.2 years ago
If what you want is just to draw the graph, you really should consider using Rgraphviz package, where "neato"/"fdp" do the layout using these algorithms. Li > Dear All, > > How can I use the numbers returned by the layout functions (like, > kamada.kawai spring layout) for actually drawing a graph? > > I could not find it in the RBGL vignettes. > > Thank you and regards, > Kaustubh
ADD COMMENT
0
Entering edit mode
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/bioconductor/attachments/20060127/ 27e9ea0f/attachment.pl
ADD REPLY
0
Entering edit mode
> Hi, > > I want to draw graph using a spring-embedding. > > Regards, > Kaustubh This takes a little bit of programming. The following is far from an ideal design, but gives some of the flavor of how you can use the RBGL layout functions. As far as I can tell there are three: circle.layout, kamada.kawai.spring.layout, and fruchtermanReingoldForceDirectedLayout. I am not sure the latter is behaving correctly, but the first two are. Now source the following function into your R session crudeGraphPlot <- function(g, alg=circle.layout, ...) { # # the alg parameter is a function that computes the # layout of g, returning it as a list of length 1 # with two rows: top row is x coordinates, bottom is # y coordinates, and node names are used as colnames # the ... are passed to segments() # layout <- alg(g)[[1]] plot( layout[1,], layout[2,], pch=nodes(g), axes=FALSE, xlab="", ylab="", main=substitute(g), cex=1.4 ) ee <- edges(g) src <- names(ee) ds <- function(nn1, nn2, lob) segments(lob[1,nn1], lob[2,nn1], lob[1,nn2], lob[2,nn2], ...) for (s in src) sapply(ee[[s]], function(x) ds(s, x, layout)) invisible(NULL) } load RBGL and do example(kamada.kawai.spring.layout). This will create a graph called coex in your workspace. Now crudeGraphPlot(coex) will give the default circular layout on your graphics device crudeGraphPlot(coex, alg=kamada.kawai.spring.layout, col="green") will show you the spring layout with green edges. You will see that the layout of the spring layout is provided by the "neato" option of Rgraphviz -- library(Rgraphviz) plot(coex, "neato") so you can use either the layouts computed by RBGL with programming like that given above, or use graphviz. There is much more configurability in the Rgraphviz package, but there may be some algorithms in RBGL not available in graphviz. > > Li Long <lilong at="" isb-sib.ch=""> wrote: > If what you want is just to draw the graph, you really should consider > using Rgraphviz package, where "neato"/"fdp" do the layout using these > algorithms. > > Li > > > Dear All, > > > > How can I use the numbers returned by the layout functions (like, > > kamada.kawai spring layout) for actually drawing a graph? > > > > I could not find it in the RBGL vignettes. > > > > Thank you and regards, > > Kaustubh > > > > > > --------------------------------- > > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor >
ADD REPLY

Login before adding your answer.

Traffic: 867 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6