当前位置: 首页>>代码示例>>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;未经允许,请勿转载。