Skip to content
Snippets Groups Projects
Commit afdf2c21 authored by Peter Wagenhuber's avatar Peter Wagenhuber
Browse files

solved the problem of ambiguous paths. closes #3

parent 22c12cf1
No related branches found
No related tags found
No related merge requests found
......@@ -142,20 +142,33 @@ public class Nloc {
return allInSink;
}
public List<List<Channel>> getDesiredPath(List<Channel> modules,
public List<Channel> getDesiredPath(List<Channel> modules,
List<List<Channel>> pathlist) throws NlocStructureException {
List<List<Channel>> found = new ArrayList<List<Channel>>();
List<Channel> found = new ArrayList<Channel>();
for (List<Channel> path : pathlist) {
//if (path.containsAll(modules) && found.isEmpty()) {
if (path.containsAll(modules)) {
found.add(path);
//} else if (path.containsAll(modules) && !found.isEmpty()) {
// throw new NlocStructureException("Paths are not unique!");
}
List<Channel> modlist = new ArrayList<Channel>();
for (Channel ch: path) {
if (ch instanceof Module) {
modlist.add(ch);
}
}
if (modules.equals(modlist) && found.isEmpty()) {
found = path;
} else if (modules.equals(modlist) && !found.isEmpty()) {
throw new NlocStructureException("Paths are not unique!");
}
}
if (found.isEmpty()) {
throw new NlocStructureException("No path found that covers all given Modules");
}
return found;
}
......
......@@ -17,7 +17,7 @@ public class TestNloc {
List<List<Channel>> pathlist = nlSX.getAllPaths();
try {
List<Channel> modulesToVisit = nlSX.getModulesByName(Arrays.asList("m4","m1","m3","h0","m5"));
List<List<Channel>> payloadPaths = nlSX.getDesiredPath(modulesToVisit, pathlist);
List<Channel> payloadPath = nlSX.getDesiredPath(modulesToVisit, pathlist);
Pump pump = nlSX.getPump();
......@@ -25,7 +25,7 @@ public class TestNloc {
List<List<Channel>> pathlist1 = nlSX.getAllPathsFromTo(pump, ch);
printPaths(pathlist);
printPaths(payloadPaths);
printPath(payloadPath);
//printPaths(pathlist1);
} catch (Exception e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment