Random Generator Seed Value
Some layout algorithms use random numbers (or randomly chosen parameters) for which they accept a user-defined seed value. For example, the Random Layout uses the random generator to compute the coordinates of the nodes.
Subclasses of
IlvGraphLayout that are designed to support this mechanism allow the user to choose one of three ways of initializing the random generator:
With a default value that is always the same.
With a user-defined seed value that can be changed when re-performing the layout.
With an arbitrary seed value, which is different each time. In this case, the random generator is initialized based on the system time.
The user chooses the initialization option depending on what happens when the layout algorithm is performed again on the same graph. If the same seed value is used, the same layout is produced, which may be the desired result. In other situations, the user may want to produce different layouts in order to select the best one. This can be achieved by performing the layout several times using different seed values.
Here is an example of how this parameter can be used in combination with the
IlvRandomLayout class in your implementation of the method
IlvGraphLayout::layout():
IlvRandomLayout* layout = new IlvRandomLayout(); IlvRandom* random = (layout->isUseSeedValueForRandomGenerator()) ? new IlvRandom(layout->getSeedValueForRandomGenerator()) : new IlvRandom(); |
To specify the seed value, use the method:
and to obtain the current value:
IlUShort IlvGraphLayout::getSeedValueForRandomGenerator() const
The default value is 0.
Note: The user-defined seed value is used only if you call the method void IlvGraphLayout::setUseSeedValueForRandomGenerator(IlBoolean option) with an IlTrue argument. |
You can read the current option using the method:
IlBoolean IlvGraphLayout::isUseSeedValueForRandomGenerator() const
To indicate whether a subclass of IlvGraphLayout supports this parameter, the following method is provided:
IlBoolean IlvGraphLayout::supportsRandomGenerator() const
The default implementation returns IlFalse. A subclass can override this method in order to return IlTrue to indicate that this parameter is supported.
Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.