Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Random Layout (Read 10744 times)
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Random Layout
Apr 6th, 2009 at 9:16am
Print Post  
Hello,

I was wondering if there was anyways to reset or create a new random number generator for the entire diagram, it seems that you can set the seed for the diagram layout algorithms but there doesn't appear to be anyways of creating a new random generator, effectively setting the random sequence generated back to its initial state?

One way around it I could think off was to recreate the layout algorithms each time i refresh the diagram, which would hopefully create a new random generator for each layout? is this right?

I guess the problem is, does the diagram as a whole have a single random generator or are they embeded within each layout class, and if they are embeded within each layout class how can I get access to them?

regards
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Random Layout
Reply #1 - Apr 6th, 2009 at 9:48am
Print Post  
Hi,

You should send the RandomSeed of layout classes only if you need their internally generated random positions to form the same sequence each time you run the layout. Otherwise keep the default RandomSeed value, and the random positions will be different each time you call Arrange().

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Random Layout
Reply #2 - Apr 6th, 2009 at 10:03am
Print Post  
well thats not entirely true,

I am setting the random seed because I want the same layout for the nodes each time i generate the diagram,

What I actually get is a random layout each time, even though randomize is set to false on the anneal and the random seed is set to 1 for the flow layout.

Does the random generator internal to the layout classes get recreated with the seed each time arrange is called? or just once for the entire lifetime of that object?

I've created my layout algorithms objects up front during programme initialisation, and set the random seed to 1, then I use those layout objects each time arrange is called.

I do not do:

Layout layoutObj =  new FlowLayout();

each time I want to arrange my diagram. but I do reset the seed each time to 1, Is there anyway of creating a new random generator inside the layout algorithms each time I want to arrange, therefor making sure that each time before I call arrange I know I will be getting the exact same number sequence generated?

Or should I just new the layout algorithm each time, although this means that because I cannot serialise the layout algorithm objects I cannot save the layout settings and they will have to be reset each time I want to call arrange.

What do you think is the best approach?

regards


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Random Layout
Reply #3 - Apr 6th, 2009 at 1:11pm
Print Post  
I can see RandomSeed only in GridLayout and SpringLayout. Is having this property in the other layouts what you need ?
  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Random Layout
Reply #4 - Apr 6th, 2009 at 2:12pm
Print Post  
no,

There is a random seed, but what I am more interested in is how that seed is being applied inside the layout classes.

Each time I call Arrange I get a completly different layout. Setting the random seed does not fix this. I only ever create 1 layout object when my application starts, rather than each time I want to arrange.

Is the RandomNumberGenerator being created each time the Arrange function is called, or is it being created Once when I create the Layout object when my application starts?

Is it possible to reset the random number generator inside each layout class?

  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Random Layout
Reply #5 - Apr 6th, 2009 at 4:46pm
Print Post  
imagine this:

public FlowLayout m_layout = null;

MyApp()
{
..
     m_layout = new FlowLayout();
     m_layout.RandomSeed = 1;
..
}


public void LayoutAllItems()
{
...
     m_layout.Arrange();
...
}

public void ReloadThenRelayout()
{
...
     m_diagram.Items.Clear();
     LoadDiagram();
     LayoutAllItems();
...
}


Now each time i reload my diagram all my nodes end up in different places. I think because the layouts internal randomiser is not being reset when I call arrange.


  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Random Layout
Reply #6 - Apr 7th, 2009 at 7:36am
Print Post  
I can't see any random numbers used in the FlowLayout code; perhaps RandomSeed was used in older versions, but no more. I suppose the layout object does not clear its state correctly on next runs. What happens if you set RecreateGraph = true? Are you using the WPF or Windows Forms control?

Stoyan
  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Random Layout
Reply #7 - Apr 7th, 2009 at 8:22am
Print Post  
WinForms,

setting recreate graph to true has the same effect different layout each time.

the flow layout in your latest release has a random seed parameter

look at this page it shows you the members for flow layout:

http://www.mindfusion.eu/onlinehelp/flowchartnet/index.htm

random seed is present. and its present on mine and compiles.

  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Random Layout
Reply #8 - Apr 7th, 2009 at 8:23am
Print Post  
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Random Layout
Reply #9 - Apr 7th, 2009 at 10:06am
Print Post  
Yes, it has RandomSeed as a property, but it is not used anymore from what I can see in the source code, nor there are any instances of the Random class created. If setting RecreateGraph does not help, could you email the diagram saved as XML to support@mindfusion.eu, and our developer will investigate this?
  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Random Layout
Reply #10 - Apr 7th, 2009 at 10:17am
Print Post  
I also get this problem when using any of the layout classes not just flow,

Is it because Im using the layout classes that exist for the lifetime of my application rather than the single instance of wanting the arrange the diagram?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Random Layout
Reply #11 - Apr 7th, 2009 at 2:14pm
Print Post  
Both SpringLayout and GridLayout have this code in their Arrange method -

if (_info.RandomSeed != 0)
     _r = new Random(_info.RandomSeed);

and subsequently use the Random instance to get random positions. So I suppose the random numbers should be the same and Arrange should produce the same result if the graph wasn't changed. However SpringLayout might start from the current positions of the nodes, so in that case each subsequent Arrange would create a different result based on the previous one.

Stoyan
  
Back to top
 
IP Logged
 
jmquinlan
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 67
Joined: Apr 2nd, 2009
Re: Random Layout
Reply #12 - Apr 7th, 2009 at 2:26pm
Print Post  
so what your saying is, that if Im placing my nodes in a different initial position each time I reload the layout algorithms will produce different result?

That might be the bug..

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Random Layout
Reply #13 - Apr 7th, 2009 at 2:39pm
Print Post  
This should happen with AnnealLayout and SpringLayout; they depend on the initial positions of nodes. FlowLayout might depend on the order in which nodes and links are added, in case you are adding them in random order...
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint