Deterministic general-purpose layout in Cytoscape plugin?

107 views
Skip to first unread message

Tim Hull

unread,
Nov 18, 2010, 10:53:40 AM11/18/10
to cytoscape-discuss
Hi,

I'm in the process of developing a plugin which creates Cytoscape
networks of varying sizes. As part of this, I am using a layout
manager to lay out the nodes. I do like how the yFiles organic layout
is deterministic (i.e. when given the same network, it always produces
an identical layout). However, as this layout is proprietary, it is
impossible to actually use it from the Cytoscape API (and even the
"hacks" that used to allow the use of yFiles from in 2.7 and before
don't work anymore in the 2.8 betas).

Anyway, does anyone have a good alternative here? Currently, I'm
using the force-directed layout, which seems to work OK - however, it
is non-deterministic (at least as it is configured out of the box).
Having a deterministic layout would be far better in this case, as
users generally expect the same input to produce the same results
(which doesn't happen with force-directed)...

Tim

Michael Heuer

unread,
Nov 18, 2010, 12:05:48 PM11/18/10
to cytoscap...@googlegroups.com
Tim Hull <thu...@umich.edu> wrote:

If you can set the seed for the random number generator in the
force-directed layout algorithm, I believe the layout should be
deterministic.

To aid this kind of algorithm configuration, it might be a good idea
to replace references to java.util.Random with
org.apache.commons.math.random.RandomGenerator

http://commons.apache.org/math/api-2.1/org/apache/commons/math/random/package-summary.html

michael

Michael Heuer

unread,
Nov 18, 2010, 1:30:03 PM11/18/10
to cytoscap...@googlegroups.com
Michael Heuer <heu...@gmail.com> wrote:
> Tim Hull <thu...@umich.edu> wrote:
>
>> I'm in the process of developing a plugin which creates Cytoscape
>> networks of varying sizes.  As part of this, I am using a layout
>> manager to lay out the nodes.  I do like how the yFiles organic layout
>> is deterministic (i.e. when given the same network, it always produces
>> an identical layout).  However, as this layout is proprietary, it is
>> impossible to actually use it from the Cytoscape API (and even the
>> "hacks" that used to allow the use of yFiles from in 2.7 and before
>> don't work anymore in the 2.8 betas).
>>
>> Anyway, does anyone have a good alternative here?  Currently, I'm
>> using the force-directed layout, which seems to work OK - however, it
>> is non-deterministic (at least as it is configured out of the box).
>> Having a deterministic layout would be far better in this case, as
>> users generally expect the same input to produce the same results
>> (which doesn't happen with force-directed)...
>
> If you can set the seed for the random number generator in the
> force-directed layout algorithm, I believe the layout should be
> deterministic.

If I'm looking in the right place, this already is the case

ForceDirectedLayout.java, line 103:
m_fsim.addForce(new NBodyForce());

NBodyForce.java, line 59:
private Random rand = new Random(12345678L); // deterministic randomness

Maybe you just need to increase the number of iterations.

michael

Tim Hull

unread,
Nov 18, 2010, 4:58:46 PM11/18/10
to cytoscape-discuss
I'm using the default configuration of the force-directed layout at
this point. I know that it isn't already deterministic because I
definitely see differences in the layout each time I run it...

Tim

On Nov 18, 1:30 pm, Michael Heuer <heue...@gmail.com> wrote:

Tim Hull

unread,
Nov 19, 2010, 10:12:43 AM11/19/10
to cytoscape-discuss
I tried upping the number of iterations, but it didn't make a
difference....

Scooter Morris

unread,
Nov 19, 2010, 1:58:16 PM11/19/10
to cytoscap...@googlegroups.com
I did a couple of simple things to fix this, and I'm getting closer.
The problem is that in order to get ForceDirected truly deterministic, I
need to reset all of the node positions before running the algorithm.
At this point, I get the same result from ForceDirected *if* I start
with the nodes in the same position. These changes will undoubtedly
not be in 2.8, which is due to release very, very soon.

-- scooter

Reply all
Reply to author
Forward
0 new messages