當前位置: 首頁>>代碼示例>>Java>>正文


Java DirectedSparseGraph.getEdges方法代碼示例

本文整理匯總了Java中edu.uci.ics.jung.graph.DirectedSparseGraph.getEdges方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectedSparseGraph.getEdges方法的具體用法?Java DirectedSparseGraph.getEdges怎麽用?Java DirectedSparseGraph.getEdges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.uci.ics.jung.graph.DirectedSparseGraph的用法示例。


在下文中一共展示了DirectedSparseGraph.getEdges方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteDoubleEdges

import edu.uci.ics.jung.graph.DirectedSparseGraph; //導入方法依賴的package包/類
/**
 * Erases the multiple edges of a graph
 * @param graph
 */
public static void deleteDoubleEdges(DirectedSparseGraph<Vertex,Edge> graph){
	HashSet<Edge> toDelete = new HashSet<Edge>();
	for (Edge edge1 : graph.getEdges()) {
		for (Edge edge2 : graph.getEdges()) {
			if(graph.getSource(edge1) == graph.getDest(edge2) 
					&& graph.getSource(edge2) == graph.getDest(edge1)
					&& !toDelete.contains(edge1)
					&& graph.getSource(edge1).toString().compareTo(graph.getDest(edge1).toString()) > 0){
				toDelete.add(edge1);
			}
		}
	}
	System.out.println(toDelete.size());
	for (Edge edge : toDelete) {
		System.out.println(graph.getEdges().contains(edge));
		graph.removeEdge(edge);	
	}	
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:23,代碼來源:Utils.java

示例2: writeEdgeList

import edu.uci.ics.jung.graph.DirectedSparseGraph; //導入方法依賴的package包/類
/**
 * Writes on the output a list of the edges of the network
 * @param graph to print
 * @param ps output stream
 */
public static void writeEdgeList(DirectedSparseGraph<Vertex,Edge> graph, PrintStream ps) {
	Hashtable<Vertex, Integer> table = new Hashtable<Vertex, Integer>();
	int count=0;
	for(Vertex v: graph.getVertices()){
		table.put(v, count);
		count++;
	}
	for(Edge e: graph.getEdges()){
		ps.println(table.get(graph.getSource(e)) + "\t"+table.get(graph.getDest(e)));
	}
	
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:18,代碼來源:Utils.java


注:本文中的edu.uci.ics.jung.graph.DirectedSparseGraph.getEdges方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。