* {@inheritDoc}
*/
@Override
public SimplePath[] findPaths(KamNode[] sources, KamNode[] targets) {
if (sources == null || sources.length == 0) {
throw new InvalidArgument(
"Source kam nodes cannot be null or empty.");
}
if (targets == null || targets.length == 0) {
throw new InvalidArgument(
"Target kam nodes cannot be null or empty.");
}
for (final KamNode source : sources) {
if (!kam.contains(source)) {
throw new InvalidArgument("Source does not exist in KAM.");
}
}
final Set<KamNode> targetSet = new HashSet<KamNode>(targets.length);
for (final KamNode target : targets) {
if (!kam.contains(target)) {
throw new InvalidArgument("Target does not exist in KAM.");
}
targetSet.add(target);
}
final List<SimplePath> pathsFound = new ArrayList<SimplePath>();
for (final KamNode source : sources) {
if (!kam.contains(source)) {
throw new InvalidArgument("Source does not exist in KAM.");
}
pathsFound.addAll(runDepthFirstSearch(kam, source, targetSet));
}