@Test public void test() throws IOException { int n = 500; tic(); DGraph<String> graph = Data.edgeListDirectedUnlabeled(new File("/Users/Peter/Documents/datasets/graphs/p2p/p2p.30.txt"), true); System.out.println("graph loaded. size: "+graph.size()+", num links: "+graph.numLinks()+""); SimpleSubgraphGenerator sgen = new SimpleSubgraphGenerator(graph, Generators.uniform(3, 7)); FrequencyModel<DGraph<String>> fm = new FrequencyModel<DGraph<String>>(); Comparator<String> comp = Functions.natural(); for(int i : series(n)) { if(i > 0 && i % (n/500) == 0) System.out.print("."); if(i > 0 && i % (n/10) == 0) System.out.println(); List<Integer> indices = sgen.generate(); DGraph<String> sub = Subgraph.dSubgraphIndices(graph,indices); Order canonical = Nauty.order(sub, comp); sub = Graphs.reorder(sub, canonical); List<Integer> occurrence = canonical.apply(indices); fm.add(sub); } System.out.println("\n time taken : " + toc()); fm.print(System.out); }
@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();  }