本文整理汇总了Java中edu.uci.ics.jung.graph.SparseGraph.addEdge方法的典型用法代码示例。如果您正苦于以下问题:Java SparseGraph.addEdge方法的具体用法?Java SparseGraph.addEdge怎么用?Java SparseGraph.addEdge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.SparseGraph
的用法示例。
在下文中一共展示了SparseGraph.addEdge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIsland
import edu.uci.ics.jung.graph.SparseGraph; //导入方法依赖的package包/类
/**
* Gets the island containing the given node
*
* @param node
* @return
*/
public Graph<V, E> getIsland( V node ) {
// just do a depth-first search of everything this node connects to
SparseGraph<V, E> island = new SparseGraph<>();
Deque<V> todo = new ArrayDeque<>();
todo.add( node );
while ( !todo.isEmpty() ) {
V vert = todo.pop();
island.addVertex( vert );
for ( E ed : graph.getIncidentEdges( vert ) ) {
if ( !island.containsEdge( ed ) ) {
V v2 = graph.getOpposite( vert, ed );
if ( !island.containsVertex( v2 ) ) {
todo.push( v2 );
}
island.addEdge( ed, vert, v2 );
}
}
}
return island;
}
示例2: updateLayout
import edu.uci.ics.jung.graph.SparseGraph; //导入方法依赖的package包/类
public void updateLayout(GraphContainer graphContainer) {
Graph g = graphContainer.getGraph();
final Layout graphLayout = g.getLayout();
SparseGraph<VertexRef, EdgeRef> jungGraph = new SparseGraph<VertexRef, EdgeRef>();
Collection<? extends Vertex> vertices = g.getDisplayVertices();
for(Vertex v : vertices) {
jungGraph.addVertex(v);
}
Collection<? extends Edge> edges = g.getDisplayEdges();
for(Edge e : edges) {
jungGraph.addEdge(e, e.getSource().getVertex(), e.getTarget().getVertex());
}
Dimension size = selectLayoutSize(graphContainer);
Dimension paddedSize = new Dimension((int)(size.getWidth()*.75), (int)(size.getHeight()*.75));
doISOMLayout(graphLayout, jungGraph, size);
doSpringLayout(graphLayout, jungGraph, size, LAYOUT_REPULSION);
doFRLayout(graphLayout, jungGraph, paddedSize, (int)(size.getWidth()/8), (int)(size.getHeight()/8));
doSpringLayout(graphLayout, jungGraph, size, LAYOUT_REPULSION);
}