diff --git a/src/Nloc.java b/src/Nloc.java index 166ce016cb5c371847039e21f9dfd10a93975087..27094c903b5349fa3b778fc4f11653508558d6ea 100644 --- a/src/Nloc.java +++ b/src/Nloc.java @@ -70,7 +70,7 @@ public class Nloc { public List<BFTableEntry> initializeBifTable(List<Channel> desiredPath) { List<BFTableEntry> bftable = new ArrayList<BFTableEntry>(); - ListIterator<Channel> iter = path.listIterator(); + ListIterator<Channel> iter = desiredPath.listIterator(); while(iter.hasNext()) { Channel current = iter.next(); if (current.isBifurcation()) { @@ -142,14 +142,15 @@ public class Nloc { return allInSink; } - public List<Channel> getDesiredPath(List<Channel> modules, + public List<List<Channel>> getDesiredPath(List<Channel> modules, List<List<Channel>> pathlist) throws NlocStructureException { - List<Channel> found = new ArrayList<Channel>(); + List<List<Channel>> found = new ArrayList<List<Channel>>(); for (List<Channel> path : pathlist) { - if (path.containsAll(modules) && found.isEmpty()) { - found = path; - } else if (path.containsAll(modules) && !found.isEmpty()) { - throw new NlocStructureException("Paths are not unique!"); + //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!"); } } if (found.isEmpty()) { diff --git a/src/TestNloc.java b/src/TestNloc.java index 140d9b1c17b86a8a1aaac1ad133f4bb1394a768f..515cc805c24f3ccf74383979dfb88d193f481bb1 100644 --- a/src/TestNloc.java +++ b/src/TestNloc.java @@ -8,25 +8,29 @@ import java.util.Arrays; public class TestNloc { - // TODO: @peda find new algorithm public static void main(String[] args) { - Nloc nlS1 = new Nloc(getNlocS1()); - Nloc nlS2 = new Nloc(getNlocS2()); - Nloc nlS6 = new Nloc(getNlocS6()); + //Nloc nlSX = new Nloc(getNlocS1()); + //Nloc nlSX = new Nloc(getNlocS2()); + Nloc nlSX = new Nloc(getNlocS6()); - List<List<Channel>> pathlist = nlS2.getAllPaths(); + 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); - printPaths(pathlist); - Pump pump = nlS2.getPump(); - Channel ch = nlS2.getModuleByName("ch26"); - List<List<Channel>> pathlist1 = nlS2.getAllPathsFromTo(pump, ch); + Pump pump = nlSX.getPump(); + Channel ch = nlSX.getModuleByName("ch15"); + List<List<Channel>> pathlist1 = nlSX.getAllPathsFromTo(pump, ch); - printPaths(pathlist1); + printPaths(pathlist); + printPaths(payloadPaths); + //printPaths(pathlist1); - - + } catch (Exception e) { + System.out.println( e.getMessage()); + } } public static void printPath(List<Channel> path) { @@ -259,8 +263,8 @@ public class TestNloc { Channel ch7 = new Channel("ch7",1,1); Channel ch8 = new Channel("ch8",1,1); Channel ch9 = new Channel("ch9",1,1); - Channel ch10 = new Channel("ch10",1,1); - Channel ch11 = new Channel("ch11",3,3); + Channel ch10 = new Channel("ch10",3,3); + Channel ch11 = new Channel("ch11",1,1); Channel ch12 = new Channel("ch12",1,1); Channel ch13 = new Channel("ch13",1,1); Channel ch14 = new Channel("ch14",3,3);