Archived
0

increase lands count if need more

This commit is contained in:
iMoHax
2015-10-15 15:25:50 +03:00
parent 61e7b3a9cb
commit 5dfd8fe571
2 changed files with 17 additions and 6 deletions

View File

@@ -70,8 +70,10 @@ public class RouteSearcher {
vGraph.build(source, vendors); vGraph.build(source, vendors);
LOG.trace("Graph is builds"); LOG.trace("Graph is builds");
RouteCollector collector = new RouteCollector(); RouteCollector collector = new RouteCollector();
Crawler<Vendor> crawler = vGraph.crawler(specificator.build(vendors, collector::add), callback); VendorsCrawlerSpecification specification = specificator.build(vendors, collector::add);
crawler.setMaxSize(scorer.getProfile().getLands()); Crawler<Vendor> crawler = vGraph.crawler(specification, callback);
int lands = Math.max(scorer.getProfile().getLands(), specification.getMinLands());
crawler.setMaxSize(lands);
crawler.findMin(target, count); crawler.findMin(target, count);
return collector.get(); return collector.get();
} }
@@ -84,11 +86,16 @@ public class RouteSearcher {
LOG.trace("Graph is builds"); LOG.trace("Graph is builds");
RouteCollector collector = new RouteCollector(); RouteCollector collector = new RouteCollector();
specificator.setGroupCount(vendors.size()); specificator.setGroupCount(vendors.size());
Crawler<Vendor> crawler = vGraph.crawler(specificator.build(vendors, collector::add, new LoopRouteSpecification<>(true), true), callback);
crawler.setMaxSize(scorer.getProfile().getLands()); VendorsCrawlerSpecification specification = specificator.build(vendors, collector::add, new LoopRouteSpecification<>(true), true);
int lands = Math.max(scorer.getProfile().getLands(), specification.getMinLands());
Crawler<Vendor> crawler = vGraph.crawler(specification, callback);
crawler.setMaxSize(lands);
crawler.findMin(source, vendors.size()); crawler.findMin(source, vendors.size());
crawler = vGraph.crawler(specificator.build(vendors, collector::add, new RouteSpecificationByTarget<>(source), false), callback); specification = specificator.build(vendors, collector::add, new RouteSpecificationByTarget<>(source), false);
crawler.setMaxSize(scorer.getProfile().getLands()); lands = Math.max(scorer.getProfile().getLands(), specification.getMinLands());
crawler = vGraph.crawler(specification, callback);
crawler.setMaxSize(lands);
crawler.findMin(source, 1); crawler.findMin(source, 1);
List<Route> routes = collector.get(); List<Route> routes = collector.get();
routes.sort((r1, r2) -> { routes.sort((r1, r2) -> {

View File

@@ -15,4 +15,8 @@ public interface CrawlerSpecification<T> {
public int getGroupCount(); public int getGroupCount();
public default int getMinLands(){
return routeSpecification() != null ? routeSpecification().matchCount() : 0;
}
} }