Problem with biograph layout
4 views (last 30 days)
I have problem with biograph layout. I went through the biograph object doc.
But my problem is with positioning nodes. I define node positions but when calling dolayout(bg,'Path', true) the places are different from the ones that I defined!? and when removing this and keeping dolayout(bg) before positioning (with e.g.: bg.nodes(7).Position=[50 200];) the pattern of my 28 nodes looks in the way that I defined but very small on a corner of the figure and the rest is empty. I think the size of the image is fixed according to auto display of the biograph and when repositioning, it keeps the previous size somehow!
In this condition the shapes of the nodes are not the one that I defined (circle); probably because not calling dolayout again. but they are not the default rectangles either, they are ellipses! so it seems to respond very unusual and not obeying any rules! I also tried bg.Scale and bg.LayoutScale too. Though when trying different combination of calling handles before, after, or in between dolayout each time you can get a new surprising layout of the nodes but still confused and can not produce the result that I want.
I don't know if this info would make any difference but my layout consists of 28 nodes with only 7 edges. so a lot of nodes are not connected and should be just there in a right position. I'll appreciate any information on that.
Lucio Cetto on 1 Feb 2011
The layout engine will readjust the size of the page according with the positions of the nodes, so, if you are going to set the positions of the nodes yourself, you just need to use a similar scale to the one it is initially provided, for example:
% I create a random graph with 28 nodes:
bg = biograph(28);
% Display it in the GUI and get a handle
% back to work with it (this will use by default
% the hierarchical layout):
hbg = view(bg);
% Get an idea of what are the actual extents of
% the page in the GUI by looking at all the current
% node positions:
page_Size = max(cell2mat(arrayfun(@(x) get(x,'Position'),...
% Place the nodes in a circular layout, in my graph
% page_size was around [1000,1000], so I will select a
% center at [500 500] and a radius of 300, this will keep
% the layout approximately in the same scale and I will
% not have to manually change the size of the nodes or
% the fonts:
radius = 300;
center = [500 500];
for i = 1:28
% Now I can use dolayout: