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); }
public void AddLink(AssetNode n) { m_links.Add(n); }
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; }