本文整理汇总了Java中edu.uci.ics.jung.graph.Forest.getVertexCount方法的典型用法代码示例。如果您正苦于以下问题:Java Forest.getVertexCount方法的具体用法?Java Forest.getVertexCount怎么用?Java Forest.getVertexCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.Forest
的用法示例。
在下文中一共展示了Forest.getVertexCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MinimumSpanningForest
import edu.uci.ics.jung.graph.Forest; //导入方法依赖的package包/类
/**
* 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
*/
public MinimumSpanningForest(Graph<V, E> graph, Forest<V,E> forest,
Collection<V> roots) {
if(forest.getVertexCount() != 0) {
throw new IllegalArgumentException("Supplied Forest must be empty");
}
this.graph = graph;
this.forest = forest;
Set<E> unfinishedEdges = new HashSet<E>(graph.getEdges());
if(roots != null && !roots.isEmpty()) {
V root = roots.iterator().next();
System.out.println(root);
roots.remove(root);
this.forest.addVertex(root);
}
updateForest(forest.getVertices(), unfinishedEdges, roots);
}
示例2: MinimumSpanningForest
import edu.uci.ics.jung.graph.Forest; //导入方法依赖的package包/类
/**
* 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
* @param weights edge weights, may be null
*/
public MinimumSpanningForest(Graph<V, E> graph, Forest<V,E> forest,
V root, Map<E, Double> weights) {
if(forest.getVertexCount() != 0) {
throw new IllegalArgumentException("Supplied Forest must be empty");
}
this.graph = graph;
this.forest = forest;
if(weights != null) {
this.weights = weights;
}
Set<E> unfinishedEdges = new HashSet<E>(graph.getEdges());
if(graph.getVertices().contains(root)) {
this.forest.addVertex(root);
}
updateForest(forest.getVertices(), unfinishedEdges);
}
示例3: MinimumSpanningForest2
import edu.uci.ics.jung.graph.Forest; //导入方法依赖的package包/类
/**
* create a 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 arbitary 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 weights edge weights, may be null
*/
public MinimumSpanningForest2(Graph<V, E> graph,
Forest<V,E> forest,
Factory<? extends Graph<V,E>> treeFactory,
Transformer<E, Double> weights) {
if(forest.getVertexCount() != 0) {
throw new IllegalArgumentException("Supplied Forest must be empty");
}
this.graph = graph;
this.forest = forest;
if(weights != null) {
this.weights = weights;
}
WeakComponentClusterer<V,E> wcc =
new WeakComponentClusterer<V,E>();
Set<Set<V>> component_vertices = wcc.transform(graph);
Collection<Graph<V,E>> components =
FilterUtils.createAllInducedSubgraphs(component_vertices, graph);
for(Graph<V,E> component : components) {
PrimMinimumSpanningTree<V,E> mst =
new PrimMinimumSpanningTree<V,E>(treeFactory, this.weights);
Graph<V,E> subTree = mst.transform(component);
if(subTree instanceof Tree) {
TreeUtils.addSubTree(forest, (Tree<V,E>)subTree, null, null);
}
}
}