/** * @param kam * @param kamEdges * @return * @throws InvalidArgument */ public static Kam difference(Kam kam, List<KamEdge> kamEdges) throws InvalidArgument { // Make sure that all the edges in the edge list are associated with the Kam for (KamEdge kamEdge : kamEdges) { if (!kamEdge.getKam().getKamInfo().equals(kam.getKamInfo())) { throw new InvalidArgument("Kamedges do not reference the same Kam."); } } // Create a new kam instance and add the edges Kam kam2 = newInstance(kam); kam2.union(kamEdges); // perform a kam to kam difference return difference(kam, kam2); }
/** * @param kam * @param kamEdges * @return * @throws InvalidArgument */ public static Kam intersection(Kam kam, List<KamEdge> kamEdges) throws InvalidArgument { // Make sure that all the edges in the edge list are associated with the Kam for (KamEdge kamEdge : kamEdges) { if (!kamEdge.getKam().getKamInfo().equals(kam.getKamInfo())) { throw new InvalidArgument("Kamedges do not reference the same Kam."); } } // Check for edges in Kam1 that are also in the list List<KamEdge> intersectionKamEdges = new ArrayList<KamEdge>(); for (KamEdge kamEdge : kamEdges) { if (kam.contains(kamEdge)) { intersectionKamEdges.add(kamEdge); } } return union(kam, intersectionKamEdges); }