Ejemplo n.º 1
0
        private void AdjustVertex(TVertex closest, CancellationToken cancellationToken)
        {
            _queue.Clear();
            var vid = _isomDataDict[closest];

            vid.Distance = 0;
            vid.Visited  = true;
            _queue.Enqueue(closest);

            while (_queue.Count > 0)
            {
                cancellationToken.ThrowIfCancellationRequested();

                var current    = _queue.Dequeue();
                var currentVid = _isomDataDict[current];
                var pos        = VertexPositions[current];

                var force  = _tempPos - pos;
                var factor = _adaptation / Math.Pow(2, currentVid.Distance);

                pos += factor * force;
                VertexPositions[current] = pos;

                //ha még a hatókörön belül van
                if (currentVid.Distance < _radius)
                {
                    //akkor a szomszedokra is hatassal vagyunk
                    foreach (var neighbour in VisitedGraph.GetNeighbours(current))
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        var nvid = _isomDataDict[neighbour];
                        if (!nvid.Visited)
                        {
                            nvid.Visited  = true;
                            nvid.Distance = currentVid.Distance + 1;
                            _queue.Enqueue(neighbour);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void AdjustVertex(TVertex closest)
        {
            _queue.Clear();
            ISOMData vid = _isomDataDict[closest];

            vid.Distance = 0;
            vid.Visited  = true;
            _queue.Enqueue(closest);

            while (_queue.Count > 0)
            {
                TVertex  current    = _queue.Dequeue();
                ISOMData currentVid = _isomDataDict[current];
                Point    pos        = VertexPositions[current];

                Vector force  = _tempPos - pos;
                double factor = _adaptation / Math.Pow(2, currentVid.Distance);

                pos += factor * force;
                VertexPositions[current] = pos;

                //ha még a hatókörön belül van
                if (currentVid.Distance < _radius)
                {
                    //akkor a szomszedokra is hatassal vagyunk
                    foreach (TVertex neighbour in VisitedGraph.GetNeighbours <TVertex, TEdge>(current))
                    {
                        ISOMData nvid = _isomDataDict[neighbour];
                        if (!nvid.Visited)
                        {
                            nvid.Visited  = true;
                            nvid.Distance = currentVid.Distance + 1;
                            _queue.Enqueue(neighbour);
                        }
                    }
                }
            }
        }