当前位置: 首页>>代码示例>>Java>>正文


Java DirectedSparseMultigraph.outDegree方法代码示例

本文整理汇总了Java中edu.uci.ics.jung.graph.DirectedSparseMultigraph.outDegree方法的典型用法代码示例。如果您正苦于以下问题:Java DirectedSparseMultigraph.outDegree方法的具体用法?Java DirectedSparseMultigraph.outDegree怎么用?Java DirectedSparseMultigraph.outDegree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uci.ics.jung.graph.DirectedSparseMultigraph的用法示例。


在下文中一共展示了DirectedSparseMultigraph.outDegree方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GraphPanel

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入方法依赖的package包/类
public GraphPanel(DirectedSparseMultigraph<V, E> graph) {
  // this.setLayout(new FlowLayout());
  DirectedSparseMultigraph<V, E> graphTemp = new DirectedSparseMultigraph<V, E>();
  for (V vertex : graph.getVertices()) {
    if (graph.inDegree(vertex) > 0 || graph.outDegree(vertex) > 0) {
      graphTemp.addVertex(vertex);
    }
  }
  for (E edge : graph.getEdges()) {
    if (graphTemp.containsVertex(graph.getSource(edge))
        && graphTemp.containsVertex(graph.getDest(edge))) {
      graphTemp.addEdge(edge, graph.getSource(edge), graph.getDest(edge));
    }
  }
  this.graph = graphTemp;
  layout = new KKLayout<V, E>(this.graph);
  layout.setSize(new Dimension(1000, 800)); // sets the initial size of the
                                            // space
  // The BasicVisualizationServer<V,E> is parameterized by the edge types
  BasicVisualizationServer<V, E> server = new BasicVisualizationServer<V, E>(
      layout);
  server.setPreferredSize(new Dimension(1000, 800));
  this.add(server);

}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:26,代码来源:GraphPanel.java

示例2: CycleChainDecomposition

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入方法依赖的package包/类
/**
 * 
 * @param graph
 *          every node in graph must have in degree at most one and out degree
 *          at most one, otherwise throws error
 */
public CycleChainDecomposition(DirectedSparseMultigraph<V, E> degreeTwoGraph) {
  this.degreeTwoGraph = degreeTwoGraph;
  this.edgeChains = Lists.newArrayList();
  this.edgeCycles = Lists.newArrayList();
  validateInput();
  WeakComponentClusterer<V, E> clusterer = new WeakComponentClusterer<V, E>();
  Set<Set<V>> connectedComponents = clusterer.transform(degreeTwoGraph);
  for (Set<V> connectedComponent : connectedComponents) {
    if (connectedComponent.size() > 1 ||
    // this condition allows for self loops
        (connectedComponent.size() == 1 && degreeTwoGraph
            .outDegree(connectedComponent.iterator().next()) > 0)) {
      Optional<V> start = findStart(connectedComponent);
      if (start.isPresent()) {
        EdgeChain<E> chain = GraphUtil.makeChain(start.get(),
            connectedComponent, degreeTwoGraph);
        edgeChains.add(chain);
      } else {
        EdgeCycle<E> cycle = GraphUtil.makeCycle(connectedComponent,
            degreeTwoGraph);
        edgeCycles.add(cycle);
      }
    }
  }
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:32,代码来源:CycleChainDecomposition.java

示例3: outDegreeOnSubgraph

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入方法依赖的package包/类
public static <V,E,T extends Comparable<T>> int[] outDegreeOnSubgraph(KepProblemDataInterface<V,E> multiPeriodCyclePacking,
		Set<V> vertices, DirectedSparseMultigraph<V,E> subgraph){

	int[] ans = new int[vertices.size()];
	int i = 0;
	for(V vertex: vertices){
		if(!subgraph.containsVertex(vertex)){
			throw new RuntimeException();
		}
		ans[i++] = subgraph.outDegree(vertex);				
	}
	return ans;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:14,代码来源:Queries.java

示例4: testSetIsCycle

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入方法依赖的package包/类
/**
 * It is assumed that connectedComponent is a connected component of the
 * graph, and that every node in the graph has in degree at most one and out
 * degree at most one
 * 
 * @param connectedComponent
 * @param integerOnlyGraph
 * @return
 */
public static <V, E> boolean testSetIsCycle(Set<V> connectedComponent,
    DirectedSparseMultigraph<V, E> degreeTwoGraph) {
  for (V node : connectedComponent) {
    if (degreeTwoGraph.inDegree(node) != 1) {
      return false;
    }
    if (degreeTwoGraph.outDegree(node) != 1) {
      return false;
    }
  }
  return true;
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:22,代码来源:GraphUtil.java

示例5: makeChain

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入方法依赖的package包/类
/**
 * It is assumed that connectedComponent is a connected component of the
 * graph, and that every node in the graph has in degree at most one and out
 * degree at most one
 * 
 * @param start
 * @param connectedComponent
 *          should contain start
 * @param degreeTwoGraph
 * @return
 */
public static <V, E> EdgeChain<E> makeChain(V start,
    Set<V> connectedComponent, DirectedSparseMultigraph<V, E> degreeTwoGraph) {
  List<E> ans = new ArrayList<E>();
  Set<V> visited = new HashSet<V>();
  if (!connectedComponent.isEmpty()) {
    visited.add(start);
    V next = start;
    for (int i = 0; i < connectedComponent.size() - 1; i++) {
      Collection<E> outEdges = degreeTwoGraph.getOutEdges(next);
      if (outEdges.size() != 1) {
        throw new RuntimeException(
            "each node must have out degree one, but found node "
                + next.toString() + " with out degree " + outEdges.size());
      }
      E edge = outEdges.iterator().next();
      ans.add(edge);
      next = degreeTwoGraph.getDest(edge);
      if (!visited.add(next)) {
        throw new RuntimeException("Visiting node : " + next.toString()
            + " twice.");
      }
    }
    if (degreeTwoGraph.outDegree(next) != 0) {
      throw new RuntimeException(
          "Chain should end on node with zero out degree.");
    }
  }
  return new EdgeChain<E>(ans);
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:41,代码来源:GraphUtil.java

示例6: outdegree

import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入方法依赖的package包/类
public Map<String,Integer> outdegree(ArrayList<String> actors, MultiMap interactions){
	
	DirectedSparseMultigraph<String, String> graph = this.generateGhaph(actors, interactions);
	
	Collection<String> vertices = graph.getVertices();
	
	Map<String,Integer> outdegreeValue = new HashMap<String, Integer>();
	
	int in;
	
	for (String student:vertices){
		in = graph.outDegree(student);
		outdegreeValue.put(student, in);
	}
	
	// Save graph
					
	this.saveGraph(graph);
	
	return outdegreeValue;
}
 
开发者ID:ProjetoAmadeus,项目名称:AmadeusLMS,代码行数:22,代码来源:SocialInteractionMethods.java


注:本文中的edu.uci.ics.jung.graph.DirectedSparseMultigraph.outDegree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。