@Test(expected=RuntimeException.class) public void testTooSmall() { UGraph<String> graph = new MapUTGraph<String, String>(); UNode<String> a = graph.add(""); UNode<String> b = graph.add(""); UNode<String> c = graph.add(""); UNode<String> d = graph.add(""); UNode<String> e = graph.add(""); b.connect(c); c.connect(d); d.connect(e); e.connect(b); SimpleSubgraphGenerator gen = new SimpleSubgraphGenerator(graph, Generators.uniform(5, 6)); gen.generate(); }
@Override public List<Integer> generate() { int restarts = 0; int depth = ints == null ? size : ints.generate(); List<Integer> result = new ArrayList<Integer>(depth); boolean success; do { success = true; result.clear(); result.add(Global.random().nextInt(graph.size())); restarts ++; if(restarts > RESTARTS) checkLCC(depth); while(result.size() < depth) if(! addNeighbor(result)) { success = false; break; } } while(!success); return result; }
SimpleSubgraphGenerator extends AbstractGenerator<List<Integer>> { @Override public List<Integer> generate() { int restarts = 0; int depth = ints == null ? size : ints.generate(); List<Integer> result = new ArrayList<Integer>(depth); boolean success; do { success = true; result.clear(); result.add(Global.random().nextInt(graph.size())); restarts ++; if(restarts > RESTARTS) checkLCC(depth); while(result.size() < depth) if(! addNeighbor(result)) { success = false; break; } } while(!success); return result; } }
SimpleSubgraphGenerator extends AbstractGenerator<List<Integer>> { @Override public List<Integer> generate() { int restarts = 0; int depth = ints == null ? size : ints.generate(); List<Integer> result = new ArrayList<Integer>(depth); boolean success; do { success = true; result.clear(); result.add(Global.random().nextInt(graph.size())); restarts ++; if(restarts > RESTARTS) checkLCC(depth); while(result.size() < depth) if(! addNeighbor(result)) { success = false; break; } } while(!success); return result; } SimpleSubgraphGenerator(Graph<?> graph, Generator<Integer> ints);  SimpleSubgraphGenerator(Graph<?> graph, int size); }
SimpleSubgraphGenerator extends AbstractGenerator<List<Integer>> { @Override public List<Integer> generate() { int restarts = 0; int depth = ints == null ? size : ints.generate(); List<Integer> result = new ArrayList<Integer>(depth); boolean success; do { success = true; result.clear(); result.add(Global.random().nextInt(graph.size())); restarts ++; if(restarts > RESTARTS) checkLCC(depth); while(result.size() < depth) if(! addNeighbor(result)) { success = false; break; } } while(!success); return result; } SimpleSubgraphGenerator(Graph<?> graph, Generator<Integer> ints);  SimpleSubgraphGenerator(Graph<?> graph, int size); @Override List<Integer> generate(); }
SimpleSubgraphGenerator extends AbstractGenerator<List<Integer>> { @Override public List<Integer> generate() { int restarts = 0; int depth = ints == null ? size : ints.generate(); List<Integer> result = new ArrayList<Integer>(depth); boolean success; do { success = true; result.clear(); result.add(Global.random().nextInt(graph.size())); restarts ++; if(restarts > RESTARTS) checkLCC(depth); while(result.size() < depth) if(! addNeighbor(result)) { success = false; break; } } while(!success); return result; } SimpleSubgraphGenerator(Graph<?> graph, Generator<Integer> ints);  SimpleSubgraphGenerator(Graph<?> graph, int size); @Override List<Integer> generate();  }