예제 #1
0
        /// <summary>
        /// Determine whether substitution is compatible with given traceNode path.
        /// </summary>
        /// <param name="traceNode">The traceNode where path begins.</param>
        /// <returns><c>True</c> for compatible trace, <c>false</c> otherwise.</returns>
        internal bool IsCompatible(TraceNode2 traceNode)
        {
            var currentNode  = traceNode;
            var currentLayer = new HashSet <NodeReference>();

            currentLayer.Add(Substitution);

            while (currentNode.PreviousNode != null)
            {
                if (_resultCache.ContainsKey(currentNode))
                {
                    //we have compatibility information stored already
                    return(cacheResultPath(traceNode, _resultCache[currentNode]));
                }

                currentLayer = makeLayerTransition(currentLayer, currentNode.CurrentEdge);
                if (currentLayer.Count == 0)
                {
                    //there is no compatible transition
                    return(cacheResultPath(traceNode, false));
                }

                currentNode = currentNode.PreviousNode;
            }

            //all transistions were compatible
            return(cacheResultPath(traceNode, true));
        }
예제 #2
0
        internal PathSubstitution(NodeReference substitution, TraceNode2 originalTrace, double rank = double.NaN)
        {
            Substitution  = substitution;
            OriginalTrace = originalTrace;

            if (double.IsNaN(rank))
            {
                Rank = CompatibleInitialNodes.Count();
            }
            else
            {
                Rank = rank;
            }
        }
예제 #3
0
        /// <summary>
        /// Caches the result along the whole path.
        /// </summary>
        private bool cacheResultPath(TraceNode2 initialNode, bool cachedValue)
        {
            var currentNode = initialNode;

            while (currentNode != null)
            {
                if (_resultCache.ContainsKey(initialNode))
                {
                    break;
                }

                _resultCache[currentNode] = cachedValue;
                currentNode = currentNode.PreviousNode;
            }

            return(cachedValue);
        }