### Question:
DivergePointsFinder { public List<Vector> find(Set<List<Vector>> lines) { List<Vector> divergePoints = new ArrayList<>(); Map<Vector, List<Vector>> directions = new HashMap<>(); for (List<Vector> line: lines) { Vector prev = null; for (Vector p: line) { if (prev != null) { if (!directions.containsKey(prev)) { directions.put(prev, new ArrayList<Vector>()); } directions.get(prev).add(p.sub(prev)); } prev = p; } } for (List<Vector> line: lines) { Vector prev = null; for (Vector p: line) { if (prev != null) { Segment s = new Segment(prev, p); for (Vector dirP: directions.keySet()) { if (p.equals(dirP) || prev.equals(dirP)) continue; if (s.contains(dirP)) { directions.get(dirP).add(p.sub(dirP)); } } } prev = p; } } for (Vector p: directions.keySet()) { List<Vector> dirs = directions.get(p); boolean isDevergePoint = false; for (int i = 0; i < dirs.size(); i++) { for (int j = i + 1; j < dirs.size(); j++) { Vector v1 = dirs.get(i); Vector v2 = dirs.get(j); isDevergePoint |= !(v1.isParallel(v2) && v1.dotProduct(v2) > 0); } } if (isDevergePoint) { divergePoints.add(p); } } return divergePoints; }  List<Vector> find(Set<List<Vector>> lines);  }### Answer:
@Test public void sameLines() { List<Vector> l1 = create(); l1.add(new Vector(0, 0)); l1.add(new Vector(10, 0)); l1.add(new Vector(10, 10)); List<Vector> l2 = create(); l2.add(new Vector(0, 0)); l2.add(new Vector(10, 0)); l2.add(new Vector(10, 10)); List<Vector> points = new DivergePointsFinder().find(lines); assertTrue(points.size() == 0); }
@Test public void divergeAtPoint() { List<Vector> l1 = create(); l1.add(new Vector(0, 0)); l1.add(new Vector(10, 0)); l1.add(new Vector(10, 10)); List<Vector> l2 = create(); l2.add(new Vector(0, 0)); l2.add(new Vector(10, 0)); l2.add(new Vector(10, -10)); List<Vector> points = new DivergePointsFinder().find(lines); assertTrue(points.size() == 1); assertEquals(new Vector(10, 0), points.get(0)); }
@Test public void divergeInMiddle() { List<Vector> l1 = create(); l1.add(new Vector(0, 0)); l1.add(new Vector(10, 0)); l1.add(new Vector(10, 10)); l1.add(new Vector(20, 10)); List<Vector> l2 = create(); l2.add(new Vector(0, 0)); l2.add(new Vector(10, 0)); l2.add(new Vector(10, 20)); l2.add(new Vector(20, 20)); List<Vector> points = new DivergePointsFinder().find(lines); assertTrue(points.size() == 1); assertEquals(new Vector(10, 10), points.get(0)); }