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


Java Graph.getEdges方法代碼示例

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


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

示例1: reverseEdges

import edu.uci.ics.jung.graph.Graph; //導入方法依賴的package包/類
/**
 * This method reverse the path "path" in the graph "graph" and returns it.
 * 
 * @param graph
 *            the input graph which will not be changed.
 * @param path
 *            the path to reverse
 * @return a new graph with the reversed path
 */
private Graph<V, E> reverseEdges(Graph<V, E> graph, List<E> path) {
	if (graph == null || path == null)
		throw new IllegalArgumentException();
	Graph<V, E> clone = new DirectedOrderedSparseMultigraph<V, E>();

	for (V v : graph.getVertices())
		clone.addVertex(v);
	for (E e : graph.getEdges())
		clone.addEdge(e, graph.getEndpoints(e));

	for (E link : path) {
		V src = clone.getSource(link);
		V dst = clone.getDest(link);
		clone.removeEdge(link);
		clone.addEdge(link, dst, src, EdgeType.DIRECTED);
	}
	return clone;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:28,代碼來源:SuurballeTarjan.java

示例2: MinimumSpanningForest

import edu.uci.ics.jung.graph.Graph; //導入方法依賴的package包/類
/**
 * Creates a minimum spanning forest from the supplied graph, populating the
 * supplied Forest, which must be empty. 
 * If the supplied root is null, or not present in the Graph,
 * then an arbitrary Graph vertex will be selected as the root.
 * If the Minimum Spanning Tree does not include all vertices of the
 * Graph, then a leftover vertex is selected as a root, and another
 * tree is created
 * @param graph the Graph to find MST in
 * @param forest the Forest to populate. Must be empty
 * @param root first Tree root, may be null
 */
public MinimumSpanningForest(Graph<V, E> graph, Forest<V,E> forest, 
        Collection<V> roots) {
    
    if(forest.getVertexCount() != 0) {
        throw new IllegalArgumentException("Supplied Forest must be empty");
    }
    this.graph = graph;
    this.forest = forest;
    Set<E> unfinishedEdges = new HashSet<E>(graph.getEdges());
    if(roots != null && !roots.isEmpty()) {
    	V root = roots.iterator().next();
    	System.out.println(root);
    	roots.remove(root);
    	this.forest.addVertex(root);
    }
    updateForest(forest.getVertices(), unfinishedEdges, roots);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:30,代碼來源:MinimumSpanningForest.java

示例3: lengthTransformation

import edu.uci.ics.jung.graph.Graph; //導入方法依賴的package包/類
/**
 * This method does the following length transformation:
 * 
 * <pre>
 *  c'(v,w) = c(v,w) - d (s,w) + d (s,v)
 * </pre>
 * 
 * @param graph1
 *            the graph
 * @param slTrans
 *            The shortest length transformer
 * @return the transformed graph
 */
private Transformer<E, Double> lengthTransformation(Graph<V, E> graph1,
		Transformer<V, Number> slTrans) {
	Map<E, Double> map = new HashMap<E, Double>();

	for (E link : graph1.getEdges()) {
		double newWeight = nev.transform(link).doubleValue()
				- slTrans.transform(graph1.getDest(link)).doubleValue()
				+ slTrans.transform(graph1.getSource(link)).doubleValue();

		map.put(link, newWeight);
	}
	return MapTransformer.getInstance(map);
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:27,代碼來源:SuurballeTarjan.java

示例4: graphToDot

import edu.uci.ics.jung.graph.Graph; //導入方法依賴的package包/類
public static void graphToDot(Graph<Vertex,Edge> graph, PrintStream ps){
	
	  ps.println("digraph g {");
         ps.println("node [style=filled, color=black, fillcolor=gray, shape=circle, label=\"\", height=.15, width=.15]");
         
         for (Vertex vertex : graph.getVertices()) {
       	  ps.println(vertex.toString() + "[label=\"" + vertex.getLabel() + "\"]");
         }
         for (Edge edge :graph.getEdges()) {
       	  ps.println( graph.getSource(edge)+ "->" + graph.getDest(edge).toString());
         }
         ps.println("}");
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:14,代碼來源:Conversion.java

示例5: validateEdgeWeights

import edu.uci.ics.jung.graph.Graph; //導入方法依賴的package包/類
/**
 * used by a test method to validate the weights of the edges by a
 * one-to-one comparison. An Edge implements a comparator based only on the
 * edge weight.
 * 
 * @param expected
 *            The original (expected) network, before exporting it
 * @param actual
 *            The actual (imported) network to be compared with the expected
 */
private void validateEdgeWeights(Graph<Vertex, Edge> expected,
		Graph<Vertex, Edge> actual) {
	List<Edge> expEdges = new ArrayList<Edge>(expected.getEdges());
	List<Edge> actEdges = new ArrayList<Edge>(actual.getEdges());

	Collections.sort(expEdges);
	Collections.sort(actEdges);
	Assert.assertEquals(expEdges, actEdges);
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:20,代碼來源:TestExportNetwork.java


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