@Test public void testAll() { Collection<UGraph<String>> all5 = Graphs.all(5, ""); assertEquals(1024, all5.size()); int sum = 0; for(UGraph<String> graph : all5) sum++; assertEquals(1024, sum); System.out.println("All size three graphs"); for(UGraph<String> graph : Graphs.all(3, "")) System.out.println(graph); System.out.println(); { Set<Graph<String>> set = new HashSet<Graph<String>>(); for(Graph<String> graph : Graphs.all(1, "")) set.add(Nauty.canonize(graph)); assertEquals(set.size(), 1); } { Set<Graph<String>> set = new HashSet<Graph<String>>(); for(Graph<String> graph : Graphs.all(2, "")) set.add(Nauty.canonize(graph)); assertEquals(set.size(), 2); } { Set<Graph<String>> set = new HashSet<Graph<String>>(); for(Graph<String> graph : Graphs.all(3, "")) set.add(Nauty.canonize(graph)); assertEquals(set.size(), 4); } { Set<Graph<String>> set = new HashSet<Graph<String>>(); for(Graph<String> graph : Graphs.all(4, "")) set.add(Nauty.canonize(graph)); assertEquals(set.size(), 11); } { Set<Graph<String>> set = new HashSet<Graph<String>>(); for(Graph<String> graph : Graphs.all(5, "")) set.add(Nauty.canonize(graph)); assertEquals(set.size(), 34); } { Set<Graph<String>> set = new HashSet<Graph<String>>(); for(Graph<String> graph : Graphs.all(6, "")) set.add(Nauty.canonize(graph)); assertEquals(set.size(), 156); } }
public static Collection<UGraph<String>> all(final int n, final String label) { final int m = (n*n-n)/2; return new AbstractCollection<UGraph<String>>() { private final Collection<BitString> master = BitString.all(m); @Override public Iterator<UGraph<String>> iterator() { return new Iterator<UGraph<String>>() { private final Iterator<BitString> bitstrings = master.iterator(); @Override public boolean hasNext() { return bitstrings.hasNext(); } @Override public UGraph<String> next() { return fromBits(bitstrings.next(), label); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { return (int) Math.pow(2, m); } }; }
Graphs { public static Collection<UGraph<String>> all(final int n, final String label) { final int m = (n*n-n)/2; return new AbstractCollection<UGraph<String>>() { private final Collection<BitString> master = BitString.all(m); @Override public Iterator<UGraph<String>> iterator() { return new Iterator<UGraph<String>>() { private final Iterator<BitString> bitstrings = master.iterator(); @Override public boolean hasNext() { return bitstrings.hasNext(); } @Override public UGraph<String> next() { return fromBits(bitstrings.next(), label); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { return (int) Math.pow(2, m); } }; } }
Graphs { public static Collection<UGraph<String>> all(final int n, final String label) { final int m = (n*n-n)/2; return new AbstractCollection<UGraph<String>>() { private final Collection<BitString> master = BitString.all(m); @Override public Iterator<UGraph<String>> iterator() { return new Iterator<UGraph<String>>() { private final Iterator<BitString> bitstrings = master.iterator(); @Override public boolean hasNext() { return bitstrings.hasNext(); } @Override public UGraph<String> next() { return fromBits(bitstrings.next(), label); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { return (int) Math.pow(2, m); } }; }  }
Graphs { public static Collection<UGraph<String>> all(final int n, final String label) { final int m = (n*n-n)/2; return new AbstractCollection<UGraph<String>>() { private final Collection<BitString> master = BitString.all(m); @Override public Iterator<UGraph<String>> iterator() { return new Iterator<UGraph<String>>() { private final Iterator<BitString> bitstrings = master.iterator(); @Override public boolean hasNext() { return bitstrings.hasNext(); } @Override public UGraph<String> next() { return fromBits(bitstrings.next(), label); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { return (int) Math.pow(2, m); } }; }  static UTGraph<L, T> shuffle(UTGraph<L, T> graph); static UTGraph<String, String> k(int size, String label); static DTGraph<String, String> dk(int size, String label); static UTGraph<String, String> line(int n, String label); static UTGraph<String, String> star(int n, String label); static UTGraph<String, String> ladder(int n, String label); static UTGraph<String, String> jbc(); static DTGraph<String, String> jbcDirected(); static UTGraph<String, String> single(String label); static List<Integer> degrees(Graph<?> graph); static List<Integer> inDegrees(DGraph<?> graph); static List<Integer> outDegrees(DGraph<?> graph); static void add(Graph<L> graph, Graph<L> addition); static void add(TGraph<L, T> graph, TGraph<L, T> addition); static UTGraph<String, String> reduce(UTGraph<L, T> graph); static Graph<String> blank(Graph<L> graph, String label); static UGraph<String> blank(UGraph<L> graph, String label); static DGraph<String> blank(DGraph<L> graph, String label); static UTGraph<String, String> blank(UTGraph<L, T> graph, String label); static DTGraph<String, String> blank(DTGraph<L, T> graph, String label); static Graph<L> reorder(Graph<L> graph, Order order); static UGraph<L> reorder(UGraph<L> graph, Order order); static DGraph<L> reorder(DGraph<L> graph, Order order); static UTGraph<L, T> reorder(UTGraph<L, T> graph, Order order); static DTGraph<L, T> reorder(DTGraph<L, T> graph, Order order); static String canonicalString(Graph<L> graph); static String canonicalString(DGraph<L> graph); static String canonicalString(UGraph<L> graph); static String canonicalString(DTGraph<L, T> graph); static String canonicalString(UTGraph<L, T> graph); static boolean isSimple(Graph<L> graph); static boolean hasSelfLoops(Graph<L> graph); static boolean hasMultiEdges(Graph<L> graph); static UGraph<L> toSimpleUGraph(Graph<L> data); static UGraph<L> toSimpleUGraph(Graph<L> data, FrequencyModel<Pair<Integer, Integer>> removals); static DGraph<L> toSimpleDGraph(DGraph<L> data); static DGraph<L> toSimpleDGraph(DGraph<L> data, FrequencyModel<Pair<Integer, Integer>> removals); static Collection<UGraph<String>> all(final int n, final String label); static List<UGraph<String>> allIso(int n, String label); static List<UGraph<String>> allIsoConnected(int n, String label); static boolean connected(UGraph<L> graph); static boolean connected(Graph<L> graph); static UGraph<String> fromBits(BitString bits, String label); }
Graphs { public static Collection<UGraph<String>> all(final int n, final String label) { final int m = (n*n-n)/2; return new AbstractCollection<UGraph<String>>() { private final Collection<BitString> master = BitString.all(m); @Override public Iterator<UGraph<String>> iterator() { return new Iterator<UGraph<String>>() { private final Iterator<BitString> bitstrings = master.iterator(); @Override public boolean hasNext() { return bitstrings.hasNext(); } @Override public UGraph<String> next() { return fromBits(bitstrings.next(), label); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } @Override public int size() { return (int) Math.pow(2, m); } }; }  static UTGraph<L, T> shuffle(UTGraph<L, T> graph); static UTGraph<String, String> k(int size, String label); static DTGraph<String, String> dk(int size, String label); static UTGraph<String, String> line(int n, String label); static UTGraph<String, String> star(int n, String label); static UTGraph<String, String> ladder(int n, String label); static UTGraph<String, String> jbc(); static DTGraph<String, String> jbcDirected(); static UTGraph<String, String> single(String label); static List<Integer> degrees(Graph<?> graph); static List<Integer> inDegrees(DGraph<?> graph); static List<Integer> outDegrees(DGraph<?> graph); static void add(Graph<L> graph, Graph<L> addition); static void add(TGraph<L, T> graph, TGraph<L, T> addition); static UTGraph<String, String> reduce(UTGraph<L, T> graph); static Graph<String> blank(Graph<L> graph, String label); static UGraph<String> blank(UGraph<L> graph, String label); static DGraph<String> blank(DGraph<L> graph, String label); static UTGraph<String, String> blank(UTGraph<L, T> graph, String label); static DTGraph<String, String> blank(DTGraph<L, T> graph, String label); static Graph<L> reorder(Graph<L> graph, Order order); static UGraph<L> reorder(UGraph<L> graph, Order order); static DGraph<L> reorder(DGraph<L> graph, Order order); static UTGraph<L, T> reorder(UTGraph<L, T> graph, Order order); static DTGraph<L, T> reorder(DTGraph<L, T> graph, Order order); static String canonicalString(Graph<L> graph); static String canonicalString(DGraph<L> graph); static String canonicalString(UGraph<L> graph); static String canonicalString(DTGraph<L, T> graph); static String canonicalString(UTGraph<L, T> graph); static boolean isSimple(Graph<L> graph); static boolean hasSelfLoops(Graph<L> graph); static boolean hasMultiEdges(Graph<L> graph); static UGraph<L> toSimpleUGraph(Graph<L> data); static UGraph<L> toSimpleUGraph(Graph<L> data, FrequencyModel<Pair<Integer, Integer>> removals); static DGraph<L> toSimpleDGraph(DGraph<L> data); static DGraph<L> toSimpleDGraph(DGraph<L> data, FrequencyModel<Pair<Integer, Integer>> removals); static Collection<UGraph<String>> all(final int n, final String label); static List<UGraph<String>> allIso(int n, String label); static List<UGraph<String>> allIsoConnected(int n, String label); static boolean connected(UGraph<L> graph); static boolean connected(Graph<L> graph); static UGraph<String> fromBits(BitString bits, String label);  }