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

            LoadIteratorCache();
        }
Ejemplo 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.");
        }
    }
Ejemplo 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);
        }
Ejemplo n.º 4
0
 public GraphEnumerable(TFollow root, GraphSearchAlgorithm graphSearchAlgorithm, Func <TFollow, IEnumerable <TFollow> > childrenProjector)
 {
     Root = root;
     GraphSearchAlgorithm = graphSearchAlgorithm;
     ChildrenProjector    = childrenProjector;
 }
Ejemplo n.º 5
0
 public GraphEnumerable(TFollow root, GraphSearchAlgorithm graphSearchAlgorithm) : this(root, graphSearchAlgorithm, (item => CommonUtility.AllPropertyChildren <TFollow>(item)))
 {
 }
Ejemplo n.º 6
0
 public GraphEnumerable(Graph <T> graph, GraphSearchAlgorithm graphSearchAlgorithm)
 {
     Graph = graph;
     GraphSearchAlgorithm = graphSearchAlgorithm;
 }
Ejemplo n.º 7
0
 public void SetAlgorythm(GraphSearchAlgorithm algorythm)
 {
     searchAlgorithm = algorythm;
 }