本文整理汇总了Java中edu.uci.ics.jung.graph.DirectedSparseMultigraph.getOutEdges方法的典型用法代码示例。如果您正苦于以下问题:Java DirectedSparseMultigraph.getOutEdges方法的具体用法?Java DirectedSparseMultigraph.getOutEdges怎么用?Java DirectedSparseMultigraph.getOutEdges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.DirectedSparseMultigraph
的用法示例。
在下文中一共展示了DirectedSparseMultigraph.getOutEdges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allChainPaths
import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入方法依赖的package包/类
/**
*
* @param graph
* @param solutions
* @param appendTo
* @param remainingDepth
*/
public static <V, E> void allChainPaths(DirectedSparseMultigraph<V,E> graph, List<List<E>> solutions,
List<E> appendTo, Set<V> visited, V currentTail, int remainingNumNodes){
if(remainingNumNodes > 0){
for(E edge : graph.getOutEdges(currentTail)){
V target = graph.getDest(edge);
if(!visited.contains(target)){
List<E> newList = new ArrayList<E>(appendTo);
newList.add(edge);
solutions.add(newList);
visited.add(target);
allChainPaths(graph, solutions,newList,visited,target,remainingNumNodes-1);
visited.remove(target);
}
}
}
}
示例2: outDegreeExcludeTerminalNodes
import edu.uci.ics.jung.graph.DirectedSparseMultigraph; //导入方法依赖的package包/类
public int outDegreeExcludeTerminalNodes(){
DirectedSparseMultigraph<V,E> graph = this.getMultiPeriodPacking().getInputs().getGraph();
int ans = 0;
for(E e: graph.getOutEdges(vertex)){
V target = graph.getDest(e);
if(!this.getMultiPeriodPacking().getInputs().getTerminalNodes().contains(target)){
ans++;
}
}
return ans;
}
示例3: 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);
}