[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Layout of nodes in a 2D graph with fixed Y-positions and ra

From: Charles Novaes de Santana
Subject: Re: [igraph] Layout of nodes in a 2D graph with fixed Y-positions and random non-overlapping X-positions
Date: Thu, 28 Jan 2016 11:34:48 +0100

Hi Tamas,

Thanks for your response and for your suggestion. I will try to follow your suggestion to create my layout without overlapping nodes. I also created a question in Stackoverflow: http://stackoverflow.com/questions/35018513/layout-of-nodes-in-a-2d-graph-with-fixed-y-positions-and-random-non-overlapping

I will let you know about any progress I make on it!



On 26 January 2016 at 22:18, Tamas Nepusz <address@hidden> wrote:
Hi Charles,

As far as I know, no one has implemented this before, but it seems
vaguely similar to the Sugiyama layout - although that one does not
consider node overlap either, mostly because the entire concept of
"overlap" is hard to define at the layout stage; igraph's layout
algorithms treat the vertices as points with zero area and know
nothing about how many pixels a vertex will cover when plotted on the
screen (mostly because it depends on too many factors). So, your best
bet is probably to find the widest label in your graph and then
"guesstimate" the width of that node by multiplying the length of the
string with some constant. Then you have an upper bound on the width
and height of a node, and you can use that to set up sensible "gaps"
in the layout.


On Tue, Jan 26, 2016 at 5:08 PM, Charles Novaes de Santana
<address@hidden> wrote:
> Dear all,
> Does any of you have an idea about how to automatically generate a layout
> for a 2D graph considering that:
> 1 - the user gives the Y-position of the nodes
> 2 - the user don't care about the X-position of the nodes
> 3 - the nodes can have different sizes
> 4 - the nodes can not overlap
> 5 - the nodes should show their numeric labels, preferably inside them
> I was planning to do this by myself, creating the X-positions according to
> the number of nodes in each "level" of the graph and to the maximum size of
> a node. And I decided to write to the list just to see if anyone have
> implemented it before and could help me.
> Please consider the code below as a starting point:
> ```
> library(igraph)
> nnodes = 100;#number of nodes is 100
> g<-erdos.renyi.game(nnodes,0.07);#random graph with nnodes nodes
> ypos<-round(runif(nnodes,min=0,max=3))#positions between 0 and 10
> mysizes<-runif(nnodes,min=8,max=16)#sizes between 3 and 10
> xpos<-runif(nnodes)
> mylayout<-as.matrix(cbind(xpos,ypos))
> png("./test.png",width=1980,height=1240,res=100)
> plot(g, layout=mylayout, vertex.size=sizes, axes = FALSE, rescale=FALSE,
> ylim=range(ypos), vertex.size=mysizes)
> dev.off();
> ```
> The resulting figure is here
> Any suggestion about how to define the vector xpos in such a way that I can
> avoid nodes to overlap? Any other suggestion to create the layout?
> Thanks for any help!
> Charles
> --
> Um axé! :)
> --
> Charles Novaes de Santana, PhD
> https://github.com/cndesantana
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help

igraph-help mailing list

Um axé! :)

Charles Novaes de Santana, PhD

reply via email to

[Prev in Thread] Current Thread [Next in Thread]