本文整理汇总了Java中edu.uci.ics.jung.algorithms.cluster.EdgeBetweennessClusterer.transform方法的典型用法代码示例。如果您正苦于以下问题:Java EdgeBetweennessClusterer.transform方法的具体用法?Java EdgeBetweennessClusterer.transform怎么用?Java EdgeBetweennessClusterer.transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.algorithms.cluster.EdgeBetweennessClusterer
的用法示例。
在下文中一共展示了EdgeBetweennessClusterer.transform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cluster
import edu.uci.ics.jung.algorithms.cluster.EdgeBetweennessClusterer; //导入方法依赖的package包/类
public static void cluster(AggregateLayout<VisualNode,VisualEdge> layout, int numEdgesToRemove, boolean groupClusters) {
Graph<VisualNode,VisualEdge> g = layout.getGraph();
layout.removeAll();
EdgeBetweennessClusterer<VisualNode,VisualEdge> clusterer = new EdgeBetweennessClusterer<VisualNode,VisualEdge>(numEdgesToRemove);
Set<Set<VisualNode>> clusterSet = clusterer.transform(g);
List<VisualEdge> edges = clusterer.getEdgesRemoved();
int i = 0;
//Clusters have same color
for (Iterator<Set<VisualNode>> cIt = clusterSet.iterator(); cIt.hasNext();) {
Set<VisualNode> vertices = cIt.next();
Color c = similarColors[i % similarColors.length];
colorCluster(vertices, c);
if(groupClusters == true) {
groupCluster(layout, vertices);
}
i++;
}
}
示例2: compute
import edu.uci.ics.jung.algorithms.cluster.EdgeBetweennessClusterer; //导入方法依赖的package包/类
/**
*
* @param fraction -- the fraction of edges that should be removed. If set to
* {@value 0.0} then a default value of {@value 0.3}, i.e.,
* {@value 30%} will be used.
*/
public void compute(double fraction) {
int edgeCount = jungGraph.getEdgeCount();
EdgeBetweennessClusterer<Integer, Integer> computer =
new EdgeBetweennessClusterer<>((int)(edgeCount * fraction));
this.communities = computer.transform(jungGraph);
}
示例3: clusterAndRecolor
import edu.uci.ics.jung.algorithms.cluster.EdgeBetweennessClusterer; //导入方法依赖的package包/类
public void clusterAndRecolor(AggregateLayout<Number,Number> layout,
int numEdgesToRemove,
Color[] colors, boolean groupClusters) {
//Now cluster the vertices by removing the top 50 edges with highest betweenness
// if (numEdgesToRemove == 0) {
// colorCluster( g.getVertices(), colors[0] );
// } else {
Graph<Number,Number> g = layout.getGraph();
layout.removeAll();
EdgeBetweennessClusterer<Number,Number> clusterer =
new EdgeBetweennessClusterer<Number,Number>(numEdgesToRemove);
Set<Set<Number>> clusterSet = clusterer.transform(g);
List<Number> edges = clusterer.getEdgesRemoved();
int i = 0;
//Set the colors of each node so that each cluster's vertices have the same color
for (Iterator<Set<Number>> cIt = clusterSet.iterator(); cIt.hasNext();) {
Set<Number> vertices = cIt.next();
Color c = colors[i % colors.length];
colorCluster(vertices, c);
if(groupClusters == true) {
groupCluster(layout, vertices);
}
i++;
}
for (Number e : g.getEdges()) {
if (edges.contains(e)) {
edgePaints.put(e, Color.lightGray);
} else {
edgePaints.put(e, Color.black);
}
}
}