本文整理汇总了Java中edu.uci.ics.jung.algorithms.shortestpath.Distance类的典型用法代码示例。如果您正苦于以下问题:Java Distance类的具体用法?Java Distance怎么用?Java Distance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Distance类属于edu.uci.ics.jung.algorithms.shortestpath包,在下文中一共展示了Distance类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newLayout
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
private Layout<Node, Edge> newLayout(final Diagram diagram) {
final Layout<Node, Edge> diagramLayout;
if (layout != null && layout.startsWith("spring")) {
diagramLayout = new SpringLayout<Node, Edge>(diagram, new ConstantTransformer(Integer.parseInt(config("spring", "100"))));
} else if (layout != null && layout.startsWith("kk")) {
Distance<Node> distance = new DijkstraDistance<Node, Edge>(diagram);
if (layout.endsWith("unweight")) {
distance = new UnweightedShortestPath<Node, Edge>(diagram);
}
diagramLayout = new KKLayout<Node, Edge>(diagram, distance);
} else if (layout != null && layout.equalsIgnoreCase("circle")) {
diagramLayout = new CircleLayout<Node, Edge>(diagram);
} else if (layout != null && layout.equalsIgnoreCase("fr")) {
diagramLayout = new FRLayout<Node, Edge>(diagram);
} else {
final LevelLayout levelLayout = new LevelLayout(diagram);
levelLayout.adjust = adjust;
diagramLayout = levelLayout;
}
return diagramLayout;
}
示例2: averageDistances
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
/**
* For each vertex <code>v</code> in <code>graph</code>,
* calculates the average shortest path length from <code>v</code>
* to all other vertices in <code>graph</code> using the metric
* specified by <code>d</code>, and returns the results in a
* <code>Map</code> from vertices to <code>Double</code> values.
* If there exists an ordered pair <code><u,v></code>
* for which <code>d.getDistance(u,v)</code> returns <code>null</code>,
* then the average distance value for <code>u</code> will be stored
* as <code>Double.POSITIVE_INFINITY</code>).
*
* <p>To calculate the average distances, ignoring edge weights if any:
* <pre>
* Map distances = GraphStatistics.averageDistances(g, new UnweightedShortestPath(g));
* </pre>
* To calculate the average distances respecting edge weights:
* <pre>
* DijkstraShortestPath dsp = new DijkstraShortestPath(g, nev);
* Map distances = GraphStatistics.averageDistances(g, dsp);
* </pre>
* where <code>nev</code> is an instance of <code>NumberEdgeValue</code> that
* is used to fetch the weight for each edge.
*
* @see edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath
* @see edu.uci.ics.jung.algorithms.shortestpath.DijkstraDistance
*/
public static Map averageDistances(ArchetypeGraph graph, Distance d)
{
Map avg_dist = new HashMap();
Set vertices = graph.getVertices();
int n = graph.numVertices();
for (Iterator outer = vertices.iterator(); outer.hasNext(); )
{
ArchetypeVertex v = (ArchetypeVertex)outer.next();
double avgPathLength = 0;
for (Iterator inner = vertices.iterator(); inner.hasNext(); )
{
ArchetypeVertex w = (ArchetypeVertex)inner.next();
if (v != w) // don't include self-distances
{
Number dist = d.getDistance(v, w);
if (dist == null)
{
avgPathLength = Double.POSITIVE_INFINITY;
break;
}
avgPathLength += dist.doubleValue();
}
}
avgPathLength /= (n - 1);
avg_dist.put(v, new Double(avgPathLength));
}
return avg_dist;
}
示例3: KKLayout
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
/**
* Creates an instance for the specified graph and distance metric.
*/
public KKLayout(Graph<V,E> g, Distance<V> distance){
super(g);
this.distance = distance;
}
示例4: KKLayout
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
public KKLayout(Graph g, Distance distance)
{
super(g);
this.distance = distance;
}
示例5: createDistance
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Distance<V> createDistance() {
return new DijkstraDistance(getGraph(), edgeWeights);
}
示例6: createDistance
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Distance<V> createDistance() {
return new UnweightedShortestPath(getGraph());
}
示例7: DistanceCentralityScorer
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
/**
* Creates an instance with the specified graph, distance metric, and
* averaging behavior.
*
* @param graph The graph on which the vertex scores are to be calculated.
* @param distance The metric to use for specifying the distance between
* pairs of vertices.
* @param averaging Specifies whether the values returned is the sum of all
* v-distances or the mean v-distance.
* @param ignore_missing Specifies whether scores for missing distances
* are to ignore missing distances or be set to null.
* @param ignore_self_distances Specifies whether distances from a vertex
* to itself should be included in its score.
*/
public DistanceCentralityScorer(Hypergraph<V,E> graph, Distance<V> distance,
boolean averaging, boolean ignore_missing,
boolean ignore_self_distances)
{
this.graph = graph;
this.distance = distance;
this.averaging = averaging;
this.ignore_missing = ignore_missing;
this.ignore_self_distances = ignore_self_distances;
this.output = new HashMap<V, Double>();
}
示例8: ClosenessCentrality
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
/**
* Creates an instance using the specified vertex/vertex distance metric.
* @param graph the input
* @param distance the vertex/vertex distance metric.
*/
public ClosenessCentrality(Hypergraph<V,E> graph, Distance<V> distance)
{
super(graph, distance, true);
}
示例9: BarycenterScorer
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
/**
* Creates an instance with the specified graph and distance metric.
* @param graph the input graph
* @param distance the distance metric to use
*/
public BarycenterScorer(Hypergraph<V,E> graph, Distance<V> distance)
{
super(graph, distance, false);
}
示例10: diameter
import edu.uci.ics.jung.algorithms.shortestpath.Distance; //导入依赖的package包/类
/**
* Returns the diameter of <code>g</code> using the metric
* specified by <code>d</code>. The diameter is defined to be
* the maximum, over all pairs of vertices <code>u,v</code>,
* of the length of the shortest path from <code>u</code> to
* <code>v</code>, or <code>Double.POSITIVE_INFINITY</code>
* if any of these distances do not exist.
* @see #diameter(ArchetypeGraph, Distance, boolean)
*/
public static double diameter(ArchetypeGraph g, Distance d)
{
return diameter(g, d, false);
}