Beispiel #1
0
        /// <summary> 
        /// Returns a path starting at start, a maximum depth (number of stops) of maxDepth
        /// will only return strings of exactly maxDepth if exactLentgh is true
        ///</summary>
        /// 
        /// <param name="start"> The starting node for the route </param>
        /// <param name="maxDepth"> The maximum length (number of stops) of the route </param>
        /// <param name="exactLength"> return only exaclt maxDepth sized routes? </param>
        /// <returns> A list of routes that match the invoked criteria </returns>
        public List<string> getSteps(Node start, int maxDepth, bool exactLength)
        {
            // So far returning nothing.
            List<string> retVal = new List<string>();
            if (maxDepth == 0)
            {
                // Stop here and Return.
                retVal.Add(start.ToString());
                return retVal;
            }

            // Need to go deeper! get Adjacencies
            Edge[] adjacent = RouteMap.GetAdjacentNodes(start);
            foreach (Edge edge in adjacent)
            {
                // Step deeper to build the path
                List<string> subGraphs = getSteps(edge.End, maxDepth - 1, exactLength);

                // For each Subgraph, mark that we were "here"
                foreach (string graph in subGraphs)
                {
                    retVal.Add(start.NodeName + "-" + graph);
                }

                // Add this < maxDepth length path
                if (!exactLength)
                {
                    retVal.Add(edge.Start.NodeName.ToString());
                }
            }

            return retVal;
        }