@Test public void testGenerate() { Graph<String> graph = Graphs.star(20, "x"); Graph<String> subTarget = Graphs.line(3, "x"); subTarget = Nauty.canonize(subTarget); SubgraphGenerator<String> gen = new SubgraphGenerator<String>(graph, 3); }
@Override public SubgraphGenerator<L>.Result generate() { int depth = n != -1 ? n : ints.generate(); Set<Node<L>> nodes = new LinkedHashSet<Node<L>>(depth); Set<Link<L>> linksChosen = new LinkedHashSet<Link<L>>(); Set<Link<L>> linksCandidates = new LinkedHashSet<Link<L>>(); boolean success = false; while(!success) { nodes.clear(); linksChosen.clear(); linksCandidates.clear(); Link<L> link = links.generate(); while(avoid(link)) link = links.generate(); linksCandidates.add(null); while(! success && ! linksCandidates.isEmpty()) { linksChosen.add(link); for(Node<L> node : link.nodes()) nodes.add(node); for(Node<L> node : nodes) if(toAvoid.contains(node)) { System.out.println("D:" + node); } if(nodes.size() == depth) { success = true; break; } linksCandidates.clear(); for(Link<L> linkChosen : linksChosen) for(Node<L> node : linkChosen.nodes()) for(Link<L> linkCandidate : node.links()) if(! linksChosen.contains(linkCandidate)) if(! avoid(linkCandidate)) linksCandidates.add(linkCandidate); if(! linksCandidates.isEmpty() ) link = Functions.choose(linksCandidates); } } return new Result( new ArrayList<Node<L>>(nodes), new ArrayList<Link<L>>(linksChosen)); }
SubgraphGenerator extends AbstractGenerator<SubgraphGenerator<L>.Result> { @Override public SubgraphGenerator<L>.Result generate() { int depth = n != -1 ? n : ints.generate(); Set<Node<L>> nodes = new LinkedHashSet<Node<L>>(depth); Set<Link<L>> linksChosen = new LinkedHashSet<Link<L>>(); Set<Link<L>> linksCandidates = new LinkedHashSet<Link<L>>(); boolean success = false; while(!success) { nodes.clear(); linksChosen.clear(); linksCandidates.clear(); Link<L> link = links.generate(); while(avoid(link)) link = links.generate(); linksCandidates.add(null); while(! success && ! linksCandidates.isEmpty()) { linksChosen.add(link); for(Node<L> node : link.nodes()) nodes.add(node); for(Node<L> node : nodes) if(toAvoid.contains(node)) { System.out.println("D:" + node); } if(nodes.size() == depth) { success = true; break; } linksCandidates.clear(); for(Link<L> linkChosen : linksChosen) for(Node<L> node : linkChosen.nodes()) for(Link<L> linkCandidate : node.links()) if(! linksChosen.contains(linkCandidate)) if(! avoid(linkCandidate)) linksCandidates.add(linkCandidate); if(! linksCandidates.isEmpty() ) link = Functions.choose(linksCandidates); } } return new Result( new ArrayList<Node<L>>(nodes), new ArrayList<Link<L>>(linksChosen)); } }
SubgraphGenerator extends AbstractGenerator<SubgraphGenerator<L>.Result> { @Override public SubgraphGenerator<L>.Result generate() { int depth = n != -1 ? n : ints.generate(); Set<Node<L>> nodes = new LinkedHashSet<Node<L>>(depth); Set<Link<L>> linksChosen = new LinkedHashSet<Link<L>>(); Set<Link<L>> linksCandidates = new LinkedHashSet<Link<L>>(); boolean success = false; while(!success) { nodes.clear(); linksChosen.clear(); linksCandidates.clear(); Link<L> link = links.generate(); while(avoid(link)) link = links.generate(); linksCandidates.add(null); while(! success && ! linksCandidates.isEmpty()) { linksChosen.add(link); for(Node<L> node : link.nodes()) nodes.add(node); for(Node<L> node : nodes) if(toAvoid.contains(node)) { System.out.println("D:" + node); } if(nodes.size() == depth) { success = true; break; } linksCandidates.clear(); for(Link<L> linkChosen : linksChosen) for(Node<L> node : linkChosen.nodes()) for(Link<L> linkCandidate : node.links()) if(! linksChosen.contains(linkCandidate)) if(! avoid(linkCandidate)) linksCandidates.add(linkCandidate); if(! linksCandidates.isEmpty() ) link = Functions.choose(linksCandidates); } } return new Result( new ArrayList<Node<L>>(nodes), new ArrayList<Link<L>>(linksChosen)); } SubgraphGenerator(Graph<L> graph, int n);  SubgraphGenerator(Graph<L> graph, int n, Collection<? extends Node<L>> toAvoid);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints, boolean probability);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints, Collection<? extends Node<L>> toAvoid); }
SubgraphGenerator extends AbstractGenerator<SubgraphGenerator<L>.Result> { @Override public SubgraphGenerator<L>.Result generate() { int depth = n != -1 ? n : ints.generate(); Set<Node<L>> nodes = new LinkedHashSet<Node<L>>(depth); Set<Link<L>> linksChosen = new LinkedHashSet<Link<L>>(); Set<Link<L>> linksCandidates = new LinkedHashSet<Link<L>>(); boolean success = false; while(!success) { nodes.clear(); linksChosen.clear(); linksCandidates.clear(); Link<L> link = links.generate(); while(avoid(link)) link = links.generate(); linksCandidates.add(null); while(! success && ! linksCandidates.isEmpty()) { linksChosen.add(link); for(Node<L> node : link.nodes()) nodes.add(node); for(Node<L> node : nodes) if(toAvoid.contains(node)) { System.out.println("D:" + node); } if(nodes.size() == depth) { success = true; break; } linksCandidates.clear(); for(Link<L> linkChosen : linksChosen) for(Node<L> node : linkChosen.nodes()) for(Link<L> linkCandidate : node.links()) if(! linksChosen.contains(linkCandidate)) if(! avoid(linkCandidate)) linksCandidates.add(linkCandidate); if(! linksCandidates.isEmpty() ) link = Functions.choose(linksCandidates); } } return new Result( new ArrayList<Node<L>>(nodes), new ArrayList<Link<L>>(linksChosen)); } SubgraphGenerator(Graph<L> graph, int n);  SubgraphGenerator(Graph<L> graph, int n, Collection<? extends Node<L>> toAvoid);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints, boolean probability);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints, Collection<? extends Node<L>> toAvoid); @Override SubgraphGenerator<L>.Result generate(); }
SubgraphGenerator extends AbstractGenerator<SubgraphGenerator<L>.Result> { @Override public SubgraphGenerator<L>.Result generate() { int depth = n != -1 ? n : ints.generate(); Set<Node<L>> nodes = new LinkedHashSet<Node<L>>(depth); Set<Link<L>> linksChosen = new LinkedHashSet<Link<L>>(); Set<Link<L>> linksCandidates = new LinkedHashSet<Link<L>>(); boolean success = false; while(!success) { nodes.clear(); linksChosen.clear(); linksCandidates.clear(); Link<L> link = links.generate(); while(avoid(link)) link = links.generate(); linksCandidates.add(null); while(! success && ! linksCandidates.isEmpty()) { linksChosen.add(link); for(Node<L> node : link.nodes()) nodes.add(node); for(Node<L> node : nodes) if(toAvoid.contains(node)) { System.out.println("D:" + node); } if(nodes.size() == depth) { success = true; break; } linksCandidates.clear(); for(Link<L> linkChosen : linksChosen) for(Node<L> node : linkChosen.nodes()) for(Link<L> linkCandidate : node.links()) if(! linksChosen.contains(linkCandidate)) if(! avoid(linkCandidate)) linksCandidates.add(linkCandidate); if(! linksCandidates.isEmpty() ) link = Functions.choose(linksCandidates); } } return new Result( new ArrayList<Node<L>>(nodes), new ArrayList<Link<L>>(linksChosen)); } SubgraphGenerator(Graph<L> graph, int n);  SubgraphGenerator(Graph<L> graph, int n, Collection<? extends Node<L>> toAvoid);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints, boolean probability);  SubgraphGenerator(Graph<L> graph, Generator<Integer> ints, Collection<? extends Node<L>> toAvoid); @Override SubgraphGenerator<L>.Result generate();  }