does a breadth search @param start start place @param end end place @return end place or null. Following the predecessors of this path leads to the start place
(Place start, Place end)
| 565 | * to the start place |
| 566 | */ |
| 567 | @Override |
| 568 | public Place breadthSearch(Place start, Place end) { |
| 569 | for(Layer layer: getLayers()){ |
| 570 | for(Place place: layer.getPlaces()){ |
| 571 | place.breadthSearchReset(); |
| 572 | } |
| 573 | } |
| 574 | start.getBreadthSearchData().marked = true; |
| 575 | |
| 576 | LinkedList<Place> queue = new LinkedList<>(); |
| 577 | queue.add(start); |
| 578 | |
| 579 | while(!queue.isEmpty()){ |
| 580 | Place v = queue.pollFirst(); |
| 581 | if(v == end) return v; |
| 582 | |
| 583 | for(Path pa: v.getPaths()){ |
| 584 | Place vi = pa.getOtherPlace(v); |
| 585 | if(!vi.getBreadthSearchData().marked && vi != v && !pa.getExit(v).equals("-")){ |
| 586 | vi.getBreadthSearchData().marked = true; |
| 587 | vi.getBreadthSearchData().predecessor = v; |
| 588 | queue.addLast(vi); |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | return null; |
| 593 | } |
| 594 | |
| 595 | // --------- listeners ----------------------------------------------------- |
| 596 | /** |