本文整理汇总了Java中edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath类的典型用法代码示例。如果您正苦于以下问题:Java UnweightedShortestPath类的具体用法?Java UnweightedShortestPath怎么用?Java UnweightedShortestPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnweightedShortestPath类属于edu.uci.ics.jung.algorithms.shortestpath包,在下文中一共展示了UnweightedShortestPath类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getShortPrefix
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
/** Returns a sequence of names labelling a shortest path from the initial node to node q. */
@SuppressWarnings("unchecked")
protected static List<Label> getShortPrefix(DirectedSparseGraph model, Vertex q){
Vertex init = DeterministicDirectedSparseGraph.findInitial(model);
UnweightedShortestPath p = new UnweightedShortestPath(model);
Iterator<Edge> pathIt = ShortestPathUtils.getPath(p, init, q).iterator();
List<Label> list = new LinkedList<Label>();
while(pathIt.hasNext()){
Edge e = pathIt.next();
Set<Label> s = (Set<Label>)e.getUserDatum(JUConstants.LABEL);
Label[] strings = s.toArray(new Label[0]);
list.add(strings[0]);
}
return list;
}
示例2: newLayout
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的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;
}
示例3: initializeLocationsFromLayout
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
public void initializeLocationsFromLayout(EmittedLayout sla) {
super.initializeLocationsFromLayout(sla);
vertices = sla.visVertexMap.keySet();
int n = vertices.size();
dm = new DenseDoubleMatrix2D(n, n);
Graph theGraph = (Graph) ((Vertex) vertices.iterator().next())
.getGraph();
unweightedShortestPaths = new UnweightedShortestPath(theGraph);
id = Indexer.getAndUpdateIndexer(theGraph, LAYOUT_INDEX_KEY);
// This is practically fast, but it would be the best if we have an
// implementation of All Pairs Shortest Paths(APSP) algorithm.
diameter = getDiameter(n, id);
int width = sla.getScreenSize().width;
int height = sla.getScreenSize().height;
double L0 = height > width ? width : height;
L = L0 / diameter * 0.9;
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
double dist = getDistance((Vertex) id.getVertex(i), (Vertex) id
.getVertex(j));
dm.setQuick(i, j, dist);
dm.setQuick(j, i, dist);
}
}
}
示例4: getPath
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
public List<E> getPath(V source, V target) {
return (ShortestPathUtils.getPath(this.graph, new UnweightedShortestPath<V, E>(this.graph), source, target));
}
示例5: KKLayout
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
/**
* Creates an instance for the specified graph.
*/
public KKLayout(Graph<V,E> g)
{
this(g, new UnweightedShortestPath<V,E>(g));
}
示例6: KKLayout
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
public KKLayout(Graph g)
{
this(g, new UnweightedShortestPath(g));
}
示例7: diameter
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
/**
* Returns the diameter of <code>g</code>, ignoring edge weights.
* @see #diameter(ArchetypeGraph, Distance, boolean)
*/
public static double diameter(ArchetypeGraph g)
{
return diameter(g, new UnweightedShortestPath((Graph)g));
}
示例8: createDistance
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Distance<V> createDistance() {
return new UnweightedShortestPath(getGraph());
}
示例9: DistanceCentralityScorer
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
/**
* Creates an instance with the specified graph and averaging behavior
* whose vertex distances are calculated on the unweighted graph.
*
* @param graph The graph on which the vertex scores are to be
* calculated.
* @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, boolean averaging,
boolean ignore_missing, boolean ignore_self_distances)
{
this(graph, new UnweightedShortestPath<V,E>(graph), averaging,
ignore_missing, ignore_self_distances);
}
示例10: averageDistances
import edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath; //导入依赖的package包/类
/**
* For each vertex <code>v</code> in <code>g</code>,
* calculates the average shortest path length from <code>v</code>
* to all other vertices in <code>g</code>, ignoring edge weights.
* @see #diameter(ArchetypeGraph, Distance)
*/
public static Map averageDistances(ArchetypeGraph g)
{
return averageDistances(g, new UnweightedShortestPath((Graph)g));
}