Rgraphviz - how to use node positions from one graph as node positions in another?
2
0
Entering edit mode
@sren-hjsgaard-1792
Last seen 7.4 years ago
Dear list, I create a "graphNEL" graph with a neato layout. I would like to get the locations of nodes in that graph and use these locations when creating subsequent graphs (such that all the graphs have the nodes in the same locations). How can this be achieved?? Apologies if this issue has come op on the list, but I haven't found it... Thanks in advance S?ren
graph graph • 1.6k views
ADD COMMENT
0
Entering edit mode
@kasper-daniel-hansen-2979
Last seen 6 months ago
United States
On Jul 24, 2007, at 3:47 PM, S?ren H?jsgaard wrote: > I create a "graphNEL" graph with a neato layout. I would like to > get the locations of nodes in that graph and use these locations > when creating subsequent graphs (such that all the graphs have the > nodes in the same locations). How can this be achieved?? Apologies > if this issue has come op on the list, but I haven't found it... Hi Soeren This is most likely going to be non-trivial. The idea of Graphviz is that it does the layout for you - ie. it assigns (x,y) positions to the nodes and a spline to the edges. What you are suggesting would require the capability of Graphviz to accept certain nodes as being fixed in the layout universe, and I don't think that is possible (I may be wrong though). You can give Graphviz a hint that certain things should be close together etc, but you are not guaranteed that the (x,y) placement will be the same once you start deleting edges. You might want to have a look at graphviz.org where they have some reasonable user guides. What you can do (and what would probably make sense if you are trying to show a graphical model, as I guess you are), is to run RGraphviz with the most complicated graph you have and then use this layout as reference. When you then delete edges/nodes you just don't draw them. This is quite easy because we render the graph in R. The code behind plot(SomeGraph.graphNEL) is essentially SomeGraph.Ragraph = layoutGraph(SomeGraph.graphNEL) The Ragraph object is now a fairly complicated object, but essentially it contains (x,y) positions etc. This object is then plotted using standard R routines in the getMethod("plot", "Ragraph") You will see the code is very straightforward, using functions such as AgNode and drawNode. With your experience it should be easy to play around with this. In case you are wondering about the abysmal naming scheme it comes from the underlying C code of Graphviz where the basic object is Agraph ("a graph" I think) with Agnode ("A graph node"), the R versions of the C objects are named accordingly. There may be an easier way I don't know about. Sometimes people can do magic with the right Graphviz settings. If you encounter some capabilities not in Rgraphvis, tell us. What you want to do makes a lot of sense from a certain perspective, so if you get some nice code working am sure we can add it in. Kasper
ADD COMMENT
0
Entering edit mode
@lilongisb-sibch-1725
Last seen 7.4 years ago
Hi, Here're a few points for you to consider: (1) "neato" draws a graph by constructing a virtual physical model, a "string" model, running an iterative solver to find a low-energy configuration; therefore the final positions of the nodes are determined by the initial positions only, user has very little control on this; you can influence (a) the initial positions by setting a random seed, (b) termination threshold, (c) edge lengths and weights; that's about all you can do; (2) from (1), it's not so easy to draw subsequent subgraphs using dynamic layout while retaining node positions; (3) if you output the "original" graph in plain text format, such as DOT, GXL, and the like, you can extract the node/edge drawing info from there, and render any subgraphs the very same positions as the original; (4) if you just want to plot the graphs in R interactively and use "agopen", you can get the node position by looking into AgNode(g)'s slot "center", which gives the x-, y-coordinates in R; (5) one way you could consider to highlight a subgraph is to give them a distinct set of attributes, such as color, shapes, so that when you apply certain set of attributes, certain subgraph stands out; along the same line, you could choose colors that obscure the unwanted, say, white for node color, font color, etc.; (6) if "subsequent graphs" have little to do with the original, then it would be a lot harder to do anything, I think; It depends a lot on what "subsequent graphs" you have and how you want to view them. Li > Dear list, > > I create a "graphNEL" graph with a neato layout. I would like to get the > locations of nodes in that graph and use these locations when creating > subsequent graphs (such that all the graphs have the nodes in the same > locations). How can this be achieved?? Apologies if this issue has come op > on the list, but I haven't found it... > > Thanks in advance > S?ren > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor >
ADD COMMENT

Login before adding your answer.

Traffic: 196 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