/// <summary>
        /// Layout the nodes in the network.
        /// </summary>
        /// <param name="config">The configuration to use.</param>
        /// <param name="maxIterations">The maximum amount of iterations after which the physics simulation ends.</param>
        public void Layout(Configuration config, int maxIterations)
        {
            var engine = new Engine();
            var state  = new BufferedState();

            int deltaT = (int)Math.Ceiling(10.0 / (double)config.UpdatesPerIteration);

            for (int i = 0; i < maxIterations * config.UpdatesPerIteration; i++)
            {
                engine.Update(deltaT, state, config);
            }

            foreach (var newNodePosition in state.NodePositions)
            {
                newNodePosition.Key.Position = new Point(newNodePosition.Value.X, newNodePosition.Value.Y);
            }
        }
Пример #2
0
        /// <summary>
        /// Layout the nodes in the network.
        /// </summary>
        /// <param name="config">The configuration to use.</param>
        /// <param name="maxIterations">The maximum amount of iterations after which the physics simulation ends.</param>
        public void Layout(Configuration config, int maxIterations)
        {
            var engine = new Engine();
            var state  = new BufferedState();

            // Move each node so no two nodes have the exact same position.
            engine.ApplyRandomShift(config.Network);

            int deltaT = (int)Math.Ceiling(10.0 / (double)config.UpdatesPerIteration);

            for (int i = 0; i < maxIterations * config.UpdatesPerIteration; i++)
            {
                engine.Update(deltaT, state, config);
            }

            foreach (var newNodePosition in state.NodePositions)
            {
                newNodePosition.Key.Position = new Point(newNodePosition.Value.X, newNodePosition.Value.Y);
            }
        }