/** * Returns a list of all the entries in the tree * * @return */ public Collection<V> getEntries() { return graph.getVertices(); }
/** * Returns a list of all the entries in the tree * * @return */ public Collection<V> getEntries() { return graph.getVertices(); }
/** * Uses a list to return all vertices, but no ordering should be implied * * @return */ public List<V> getAllNodes() { return new ArrayList<V>(graph.getVertices()); }
/** * Uses a list to return all vertices, but no ordering should be implied * * @return */ public List<V> getAllNodes() { return new ArrayList<V>(graph.getVertices()); }
@Override public synchronized ImmutableList<T> getServices() { return ImmutableList.copyOf(graph.getVertices()); }
@Override public synchronized boolean contains(@Nonnull T service) { checkNotNull(service); return graph .getVertices() .contains(service); }
/** * Returns the node contained in the tree which matches (equals) the supplied {@code node} * * @param node * @return */ public V getNode(V node) { Collection<V> x = graph.getVertices(); List<V> list = new ArrayList<V>(x); int n = list.indexOf(node); if (n < 0) { return null; } return list.get(n); }
/** * Returns the node contained in the tree which matches (equals) the supplied {@code node} * * @param node * @return */ public V getNode(V node) { Collection<V> x = graph.getVertices(); List<V> list = new ArrayList<V>(x); int n = list.indexOf(node); if (n < 0) { return null; } return list.get(n); }
private Collection<Double> getDepths() { Set<Double> depths = new HashSet<Double>(); Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations(); for(String v : graph.getVertices()) { PolarPoint pp = polarLocations.get(v); depths.add(pp.getRadius()); } return depths; }
private Collection<Double> getDepths() { Set<Double> depths = new HashSet<Double>(); Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations(); for(String v : graph.getVertices()) { PolarPoint pp = polarLocations.get(v); depths.add(pp.getRadius()); } return depths; }
private Collection<Double> getDepths() { Set<Double> depths = new HashSet<Double>(); Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations(); for(String v : graph.getVertices()) { PolarPoint pp = polarLocations.get(v); depths.add(pp.getRadius()); } return depths; }
private Collection<Double> getDepths() { Set<Double> depths = new HashSet<Double>(); Map<String,PolarPoint> polarLocations = radialLayout.getPolarLocations(); for(String v : graph.getVertices()) { PolarPoint pp = polarLocations.get(v); depths.add(pp.getRadius()); } return depths; }
unfinishedEdges.remove(nextEdge); forest.addEdge(nextEdge, currentVertex, nextVertex); updateForest(forest.getVertices(), unfinishedEdges); leftovers.removeAll(forest.getVertices()); if(leftovers.size() > 0) { V anotherRoot = leftovers.iterator().next(); forest.addVertex(anotherRoot); updateForest(forest.getVertices(), unfinishedEdges);
unfinishedEdges.remove(nextEdge); forest.addEdge(nextEdge, currentVertex, nextVertex); updateForest(forest.getVertices(), unfinishedEdges); leftovers.removeAll(forest.getVertices()); if (leftovers.size() > 0) { V anotherRoot = leftovers.iterator().next(); forest.addVertex(anotherRoot); updateForest(forest.getVertices(), unfinishedEdges);
this.forest.addVertex(root); updateForest(forest.getVertices(), unfinishedEdges);
this.forest.addVertex(root); updateForest(forest.getVertices(), unfinishedEdges);
this.forest.addVertex(root); updateForest(forest.getVertices(), unfinishedEdges);
/** * Creates a minimum spanning forest from the supplied graph, populating the * supplied Forest, which must be empty. * If the supplied root is null, or not present in the Graph, * then an arbitrary Graph vertex will be selected as the root. * If the Minimum Spanning Tree does not include all vertices of the * Graph, then a leftover vertex is selected as a root, and another * tree is created * @param graph the Graph to find MST in * @param forest the Forest to populate. Must be empty * @param root first Tree root, may be null */ @SuppressWarnings("unchecked") public MinimumSpanningForest(Graph<V, E> graph, Forest<V,E> forest, V root) { if(forest.getVertexCount() != 0) { throw new IllegalArgumentException("Supplied Forest must be empty"); } this.graph = graph; this.forest = forest; this.weights = (Function<E, Double>) Functions.constant(1.0); Set<E> unfinishedEdges = new HashSet<E>(graph.getEdges()); if(graph.getVertices().contains(root)) { this.forest.addVertex(root); } updateForest(forest.getVertices(), unfinishedEdges); }
/** * Creates a minimum spanning forest from the supplied graph, populating the * supplied Forest, which must be empty. * If the supplied root is null, or not present in the Graph, * then an arbitrary Graph vertex will be selected as the root. * If the Minimum Spanning Tree does not include all vertices of the * Graph, then a leftover vertex is selected as a root, and another * tree is created * @param graph the Graph to find MST in * @param forest the Forest to populate. Must be empty * @param root first Tree root, may be null */ @SuppressWarnings("unchecked") public MinimumSpanningForest(Graph<V, E> graph, Forest<V,E> forest, V root) { if(forest.getVertexCount() != 0) { throw new IllegalArgumentException("Supplied Forest must be empty"); } this.graph = graph; this.forest = forest; this.weights = LazyMap.decorate(new HashMap<E,Double>(), new ConstantTransformer(1.0)); Set<E> unfinishedEdges = new HashSet<E>(graph.getEdges()); if(graph.getVertices().contains(root)) { this.forest.addVertex(root); } updateForest(forest.getVertices(), unfinishedEdges); }
this.forest.addVertex(root); updateForest(forest.getVertices(), unfinishedEdges);