### Question:
Nauty { public static <T> List<List<Node<T>>> refine(List<List<Node<T>>> partition) { List<List<Node<T>>> result = new ArrayList<List<Node<T>>>(); for(List<Node<T>> cell : partition) result.add(new ArrayList<Node<T>>(cell)); while(searchShattering(result)); return result; }  static Order order(Graph<L> graph, Comparator<L> comp ); static Order order(UGraph<L> graph, Comparator<L> comp); static Order order(DGraph<L> graph, Comparator<L> comp); static List<List<Node<L>>> partition(Graph<L> graph, Comparator<L> comp); static List<List<Node<T>>> refine(List<List<Node<T>>> partition); static List<List<Node<L>>> refine(List<List<Node<L>>> partition, List<T> tags); static List<List<Node<L>>> shattering(List<Node<L>> from, List<Node<L>> to); static List<List<Node<L>>> shattering(List<Node<L>> from, List<Node<L>> to, T tag); static boolean shatters(List<Node<L>> from, List<Node<L>> to); static T shatters(List<Node<L>> from, List<Node<L>> to, List<T> tags); static int degree(Node<L> from, List<Node<L>> to); @SuppressWarnings("unchecked") static int degree(Node<L> from, List<Node<L>> to, T tag); static Graph<L> canonize(Graph<L> graph);  }### Answer:
@SuppressWarnings("unchecked") @Test public void testRefine1() { Graph<String> graph = graph(); List<List<Node<String>>> unitPartition = new ArrayList<List<Node<String>>>(); unitPartition.add(new ArrayList<Node<String>>(graph.nodes())); List<List<Node<String>>> expected = new ArrayList<List<Node<String>>>(); expected.add(asList(graph.node("a"), graph.node("c"), graph.node("g"), graph.node("i"))); expected.add(asList(graph.node("b"), graph.node("d"), graph.node("f"), graph.node("h"))); expected.add(asList(graph.node("e"))); assertEquals(expected, Nauty.refine(unitPartition)); }
@SuppressWarnings("unchecked") public void testRefine1Directed() { Graph<String> graph = graphDirected(); List<List<Node<String>>> unitPartition = new ArrayList<List<Node<String>>>(); unitPartition.add(new ArrayList<Node<String>>(graph.nodes())); List<List<Node<String>>> expected = new ArrayList<List<Node<String>>>(); expected.add(asList(graph.node("i"))); expected.add(asList(graph.node("c"), graph.node("g"))); expected.add(asList(graph.node("f"), graph.node("h"))); expected.add(asList(graph.node("a"))); expected.add(asList(graph.node("e"))); expected.add(asList(graph.node("b"), graph.node("d"))); assertEquals(expected, Nauty.refine(unitPartition)); }
@SuppressWarnings("unchecked") @Test public void testRefine2() { Graph<String> graph = graph(); List<List<Node<String>>> partition = new ArrayList<List<Node<String>>>(); partition.add(asList(graph.node("a"))); partition.add(asList(graph.node("c"), graph.node("g"), graph.node("i"))); partition.add(asList(graph.node("b"), graph.node("d"), graph.node("f"), graph.node("h"))); partition.add(asList(graph.node("e"))); List<List<Node<String>>> expected = new ArrayList<List<Node<String>>>(); expected.add(asList(graph.node("a"))); expected.add(asList(graph.node("c"), graph.node("g"))); expected.add(asList(graph.node("i"))); expected.add(asList(graph.node("f"), graph.node("h"))); expected.add(asList(graph.node("b"), graph.node("d"))); expected.add(asList(graph.node("e"))); assertEquals(expected, Nauty.refine(partition)); }