Esempio n. 1
0
        public GraphEnumerator(Graph <T> graph, GraphSearchAlgorithm graphSearchAlgorithm)
        {
            Graph = graph;
            GraphSearchAlgorithm = graphSearchAlgorithm;

            LoadIteratorCache();
        }
Esempio n. 2
0
    public void BeginSearch(string algorythm, Node start, Node goal, int framesPerSecond, int beamPaths)
    {
        if (algorythm != null)
        {
            switch (algorythm)
            {
            case ("BFS"):
                searchAlgorithm = new BFS();
                break;

            case ("DFS"):
                searchAlgorithm = new DFS();
                break;

            case ("Hill Climbing"):
                searchAlgorithm = new HillClimbing();
                break;

            case ("Beam"):
                searchAlgorithm = new Beam(beamPaths);
                break;

            case ("Branch and Bound"):
                searchAlgorithm = new BranchAndBound();
                break;

            case ("A*"):
                searchAlgorithm = new AStar();
                break;

            default:
                searchAlgorithm = null;
                break;
            }

            if (searchAlgorithm != null)
            {
                ResetAllPaths();

                Debug.LogFormat("Building a path using {0}.", algorythm);
                searchCoroutine = StartCoroutine(searchAlgorithm.Search(GraphGenerator.Nodes, GraphGenerator.Size, start, goal, framesPerSecond));
            }
            else
            {
                Debug.LogWarning("Invalid algorythm. Search canceled.");
            }
        }
        else
        {
            Debug.LogWarning("Algorythm not set. Search canceled.");
        }
    }
Esempio n. 3
0
        public GraphEnumerator(TFollow root, GraphSearchAlgorithm graphSearchAlgorithm, Func <TFollow, IEnumerable <TFollow> > childrenProjector)
        {
            Root = root;
            GraphSearchAlgorithm = graphSearchAlgorithm;
            ChildrenProjector    = childrenProjector;

            _visited = new HashSet <TFollow>();
            switch (GraphSearchAlgorithm)
            {
            case GraphSearchAlgorithm.BreadthFirstSearch:
                _remaining = new FirstInFirstOutCollection <TFollow>();
                break;

            case GraphSearchAlgorithm.DepthFirstSearch:
                _remaining = new LastInFirstOutCollection <TFollow>();
                break;

            default:
                throw new ArgumentException("Unknown graph search algorithm", "graphSearchAlgorithm");
            }

            _remaining.Add(Root);
        }
Esempio n. 4
0
 public GraphEnumerable(TFollow root, GraphSearchAlgorithm graphSearchAlgorithm, Func <TFollow, IEnumerable <TFollow> > childrenProjector)
 {
     Root = root;
     GraphSearchAlgorithm = graphSearchAlgorithm;
     ChildrenProjector    = childrenProjector;
 }
Esempio n. 5
0
 public GraphEnumerable(TFollow root, GraphSearchAlgorithm graphSearchAlgorithm) : this(root, graphSearchAlgorithm, (item => CommonUtility.AllPropertyChildren <TFollow>(item)))
 {
 }
Esempio n. 6
0
 public GraphEnumerable(Graph <T> graph, GraphSearchAlgorithm graphSearchAlgorithm)
 {
     Graph = graph;
     GraphSearchAlgorithm = graphSearchAlgorithm;
 }
Esempio n. 7
0
 public void SetAlgorythm(GraphSearchAlgorithm algorythm)
 {
     searchAlgorithm = algorythm;
 }