Exemplo n.º 1
0
        /// <summary>
        /// Updates the vertex info object with the given vertex.
        /// </summary>
        private void UpdateVertexInfo(uint v)
        {
            // update vertex info.
            _vertexInfo.Clear();
            _vertexInfo.Vertex = v;
            var contracted = 0;

            _contractionCount.TryGetValue(v, out contracted);
            _vertexInfo.ContractedNeighbours = contracted;
            var depth = 0;

            _depth.TryGetValue(v, out depth);
            _vertexInfo.Depth = depth;

            // calculate shortcuts and witnesses.
            _vertexInfo.AddRelevantEdges(_graph.GetEdgeEnumerator());
            _vertexInfo.BuildShortcuts(_weightHandler);
            _vertexInfo.Shortcuts.RemoveWitnessed(v, _witnessCalculator);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the vertex info object with the given vertex.
        /// </summary>
        /// <returns>True if witness paths have been found.</returns>
        private bool UpdateVertexInfo(uint v)
        {
            var contracted = 0;
            var depth      = 0;

            // update vertex info.
            _vertexInfo.Clear();
            _vertexInfo.Vertex = v;
            _contractionCount.TryGetValue(v, out contracted);
            _vertexInfo.ContractedNeighbours = contracted;
            _depth.TryGetValue(v, out depth);
            _vertexInfo.Depth = depth;

            // calculate shortcuts and witnesses.
            _vertexInfo.AddRelevantEdges(_graph.GetEdgeEnumerator());
            _vertexInfo.BuildShortcuts(_weightHandler);

            // check if any of neighbours are in witness queue.
            if (_witnessQueue.Count > 0)
            {
                var c = 0;
                for (var i = 0; i < _vertexInfo.Count; i++)
                {
                    var m = _vertexInfo[i];
                    if (_witnessQueue.Contains(m.Neighbour))
                    {
                        c++;
                        if (c > 1)
                        {
                            this.DoWitnessQueue();
                            break;
                        }
                    }
                }
            }

            if (_vertexInfo.RemoveShortcuts(_witnessGraph, _weightHandler))
            {
                return(true);
            }
            return(false);
        }