Add extra end condition for hybrid phase 3

This commit is contained in:
Pitchaya Boonsarngsuk
2018-02-12 08:26:07 +00:00
parent 6813be06df
commit 5ee568b1cb
2 changed files with 12 additions and 3 deletions

View File

@@ -151,9 +151,9 @@ The hybrid layout algorithm reduces the computation power usage even further by
Creates a new hybrid layout simulation default parameters. The simulation will takeover control of [d3.forceSimulation](https://github.com/d3/d3-force#forceSimulation) provided (*simulation* parameter). *forceSample* and *forceFull* are pre-configured [d3.forceNeighbourSampling](#forceNeighbourSampling) forces to be run over the $\sqrt{n}$ samples and full dataset respectively. While unsupported, other D3 forces such as [d3.forceLinkFullyConnected](forceLinkFullyConnected) may also work.
*forceSample* may have [stableVelocity](neighbourSampling_stableVelocity) configured to end the simulation and begin the interpolation phase early, but any [handler](neighbourSampling_onStableVelo) functions will be replaced be hybridSimulation's own internal function.
*forceSample* and *forceFull* may have [stableVelocity](neighbourSampling_stableVelocity) configured to end the simulation and begin the interpolation phase early, but any [handler](neighbourSampling_onStableVelo) functions will be replaced be hybridSimulation's own internal function.
*forceSample* may be absent, null, or undefined to skip the final refinement.
*forceFull* may also be absent, null, or undefined to skip the final refinement.
*simulation* should have already been loaded with nodes. If there are any changes in the list of nodes, the simulation have to be re-set using the [.simulation](#hybrid_simulation) method.
@@ -175,7 +175,7 @@ If *force* is specified, sets the neighbour and sampling force to run on the $\s
<a name="hybrid_forceFull" href="#hybrid_forceFull">#</a> *hybrid*.**forceFull**([*force*])
If *force* is specified, sets the neighbour and sampling force to run on the whole dataset after interpolation and returns this layout simulation. If set to null, the process will be skipped. If *force* is not specified, returns the current force object.
If *force* is specified, sets the neighbour and sampling force to run on the whole dataset after interpolation and returns this layout simulation. The same limitation applies: [stableVelocity](neighbourSampling_stableVelocity) may be configured to end the simulation and begin the interpolation phase early, but any [handler](neighbourSampling_onStableVelo) functions will be replaced be hybridSimulation's own internal function. If set to null, the process will be skipped. If *force* is not specified, returns the current force object.
<a name="hybrid_sampleIterations" href="#hybrid_sampleIterations">#</a> *hybrid*.**sampleIterations**([*iterations*])

View File

@@ -63,6 +63,10 @@ export default function (sim, forceS, forceF) {
forceSample.onStableVelo(sampleEnded);
}
if (forceFull.onStableVelo) {
forceFull.onStableVelo(fullEnded);
}
// Set default value for interpDistanceFn if not been specified yet
if(interpDistanceFn === undefined) {
if(forceFull.distance == 'function')
@@ -96,6 +100,11 @@ export default function (sim, forceS, forceF) {
function fullTick() {
event.call("fullTick");
if(++alreadyRanIterations >= FULL_ITERATIONS){
fullEnded();
}
}
function fullEnded() {
simulation.stop();
initAlready = false;
simulation.force("Full force", null);