本文整理汇总了Java中edu.uci.ics.jung.algorithms.shortestpath.DistanceStatistics类的典型用法代码示例。如果您正苦于以下问题:Java DistanceStatistics类的具体用法?Java DistanceStatistics怎么用?Java DistanceStatistics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DistanceStatistics类属于edu.uci.ics.jung.algorithms.shortestpath包,在下文中一共展示了DistanceStatistics类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateGraph
import edu.uci.ics.jung.algorithms.shortestpath.DistanceStatistics; //导入依赖的package包/类
@Override
protected String evaluateGraph(Graph<IVertex, IEdge> graph) {
return String.format("%.0f", DistanceStatistics.diameter(graph));
}
示例2: initialize
import edu.uci.ics.jung.algorithms.shortestpath.DistanceStatistics; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void initialize() {
currentIteration = 0;
if(graph != null && size != null) {
double height = size.getHeight();
double width = size.getWidth();
int n = graph.getVertexCount();
dm = new double[n][n];
vertices = (V[])graph.getVertices().toArray();
xydata = new Point2D[n];
// assign IDs to all visible vertices
while(true) {
try {
int index = 0;
for(V v : graph.getVertices()) {
Point2D xyd = transform(v);
vertices[index] = v;
xydata[index] = xyd;
index++;
}
break;
} catch(ConcurrentModificationException cme) {}
}
diameter = DistanceStatistics.<V,E>diameter(graph, distance, true);
double L0 = Math.min(height, width);
L = (L0 / diameter) * length_factor; // length_factor used to be hardcoded to 0.9
//L = 0.75 * Math.sqrt(height * width / n);
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
Number d_ij = distance.getDistance(vertices[i], vertices[j]);
Number d_ji = distance.getDistance(vertices[j], vertices[i]);
double dist = diameter * disconnected_multiplier;
if (d_ij != null)
dist = Math.min(d_ij.doubleValue(), dist);
if (d_ji != null)
dist = Math.min(d_ji.doubleValue(), dist);
dm[i][j] = dm[j][i] = dist;
}
}
}
}
示例3: actionPerformed
import edu.uci.ics.jung.algorithms.shortestpath.DistanceStatistics; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
final GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent();
final MyVisualizationViewer vv = (MyVisualizationViewer) viewerPanel.getVisualizationViewer();
JFrame frame1 = new JFrame(" Graph Statistics ");
frame1.setSize(600, 400);
frame1.getContentPane().setLayout(new BorderLayout());
JTextPane text = new JTextPane();
text.setEditable(true);
double diameterCurrent = DistanceStatistics.diameter(viewerPanel.getCurrentGraph());
double diameterEntire = DistanceStatistics.diameter(viewerPanel.getEntireGraph());
// Transformer transformer = DistanceStatistics.averageDistances(viewerPanel.getCurrentGraph(), new UnweightedShortestPath(viewerPanel.getCurrentGraph()));
StringBuffer sb = new StringBuffer();
sb.append("Current Graph Number of Nodes: " + viewerPanel.getCurrentGraph().getVertexCount()+"\n");
sb.append("Current Graph Number of Edges: " + viewerPanel.getCurrentGraph().getEdgeCount()+"\n");
sb.append("Entire Graph Number of Nodes: " + viewerPanel.getEntireGraph().getVertexCount()+"\n");
sb.append("Entire Graph Number of Edges: " + viewerPanel.getEntireGraph().getEdgeCount()+"\n");
sb.append("Number of selected Nodes: " + viewerPanel.getPickedVerteces().size()+"\n");
sb.append(String.format("%s: %2f \n", "Current Graph Diameter", diameterCurrent));
sb.append(String.format("%s: %2f \n", "Entire Graph Diameter", diameterEntire));
// sb.append(transformer.toString());
// sb.append(String.format("%s: %2f \n", "AverageDistances",DistanceStatistics.averageDistances(viewerPanel.getCurrentGraph())));
text.setText(sb.toString());
JScrollPane scrollPane = new JScrollPane(text);
frame1.getContentPane().add("Center", scrollPane);
frame1.setVisible(true);
}