本文整理汇总了Java中edu.uci.ics.jung.graph.Graph.getEndpoints方法的典型用法代码示例。如果您正苦于以下问题:Java Graph.getEndpoints方法的具体用法?Java Graph.getEndpoints怎么用?Java Graph.getEndpoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.Graph
的用法示例。
在下文中一共展示了Graph.getEndpoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import edu.uci.ics.jung.graph.Graph; //导入方法依赖的package包/类
@Override
public Shape transform(Context<Graph<V, E>, E> context) {
// --- Get the shape for this edge, returning either the --------------
// --- shared instance or, in the case of self-loop edges, the --------
// --- SimpleLoop shared instance.
Graph<V,E> graph = context.graph;
E e = context.element;
Pair<V> endpoints = graph.getEndpoints(e);
if(endpoints != null) {
boolean isLoop = endpoints.getFirst().equals(endpoints.getSecond());
if (isLoop) {
return this.getLoop().transform(context);
}
}
// --- Return the edge shape ------------------------------------------
if (e instanceof GraphEdge) {
return this.getGeneralPath((GraphEdge)e);
} else {
return this.getLine();
}
}
示例2: main
import edu.uci.ics.jung.graph.Graph; //导入方法依赖的package包/类
public static void main(String[] args) {
// create FNSS topology
Topology topology = new Topology();
topology.addEdge("1", "2", new Edge());
topology.addEdge("2", "3", new Edge());
// convert to JGraphT
Graph<String, Edge> graph = JUNGConverter.getGraph(topology);
// Find shortest paths
String source = "3";
String destination = "1";
DijkstraShortestPath<String, Edge> shortestPath =
new DijkstraShortestPath<String, Edge>(graph);
List<Edge> path = shortestPath.getPath(source, destination);
// Print results
System.out.println("Shortest path from " + source + " to " + destination + ":");
for (Edge e : path) {
Pair<String> endpoints = graph.getEndpoints(e);
System.out.println(endpoints.getFirst() + " -> " + endpoints.getSecond());
}
}
示例3: DeleteEdgeUndoableAction
import edu.uci.ics.jung.graph.Graph; //导入方法依赖的package包/类
public DeleteEdgeUndoableAction(Graph<Vertex, Edge> graph, Edge edge) {
this.graph = graph;
this.edge = edge;
this.endpoints = graph.getEndpoints(edge);
}