示例#1
0
        public bool FindRoute(AssetNode start, AssetNode end, List <int> visitedAssets, List <AssetNode> route, List <List <AssetNode> > allRoutes)
        {
            if (!visitedAssets.Contains(start.m_asset.id))
            {
                Console.Write(start.m_asset.symbol + "->");

                visitedAssets.Add(start.m_asset.id);

                route.Add(start);

                if (start == end)
                {
                    // done
                    return(true);
                }
                else
                {
                    foreach (AssetNode link in start.m_links)
                    {
                        if (FindRoute(link, end, visitedAssets, route, allRoutes))
                        {
                            Console.WriteLine("win");
                        }
                        else
                        {
                            Console.WriteLine("fail");
                        }

                        visitedAssets.RemoveRange(1, visitedAssets.Count - 1);
                    }
                }
            }

            return(false);
        }
示例#2
0
 public void AddLink(AssetNode n)
 {
     m_links.Add(n);
 }
示例#3
0
 public void AddLink(AssetNode n)
 {
     m_links.Add(n);
 }
示例#4
0
        public bool FindRoute(AssetNode start, AssetNode end, List<int> visitedAssets, List<AssetNode> route, List<List<AssetNode>> allRoutes)
        {
            if (!visitedAssets.Contains(start.m_asset.id))
            {
                Console.Write(start.m_asset.symbol+"->");

                visitedAssets.Add(start.m_asset.id);

                route.Add(start);

                if (start == end)
                {
                    // done
                    return true;
                }
                else
                {
                    foreach (AssetNode link in start.m_links)
                    {
                        if (FindRoute(link, end, visitedAssets, route, allRoutes))
                        {
                            Console.WriteLine("win");
                        }
                        else
                        {
                            Console.WriteLine("fail");
                        }

                        visitedAssets.RemoveRange(1, visitedAssets.Count - 1);
                    }
                }
            }

            return false;
        }