本文整理汇总了Java中edu.uci.ics.jung.graph.DirectedGraph.getOpposite方法的典型用法代码示例。如果您正苦于以下问题:Java DirectedGraph.getOpposite方法的具体用法?Java DirectedGraph.getOpposite怎么用?Java DirectedGraph.getOpposite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.DirectedGraph
的用法示例。
在下文中一共展示了DirectedGraph.getOpposite方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEdge
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
private static SEMOSSEdge getEdge( URI endpoint, SEMOSSVertex middle,
DirectedGraph<SEMOSSVertex, SEMOSSEdge> graph, boolean upstream ) {
Collection<SEMOSSEdge> edges = ( upstream ? graph.getInEdges( middle )
: graph.getOutEdges( middle ) );
for ( SEMOSSEdge edge : edges ) {
SEMOSSVertex opp = graph.getOpposite( middle, edge );
if ( opp.getType().equals( endpoint ) ) {
return edge;
}
}
return null;
}
示例2: addEdges
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
private static DirectedGraph<Integer, WeightedEdge> addEdges(List<Integer> list, DirectedGraph<Integer, WeightedEdge> dg) throws JohnsonIllegalStateException {
if (list == null) { throw new JohnsonIllegalStateException(); }
if (dg == null) { throw new JohnsonIllegalStateException(); }
DirectedGraph<Integer, WeightedEdge> result = new DirectedSparseGraph<Integer, WeightedEdge>();
for (Integer i : list) {
for (WeightedEdge edge : dg.getOutEdges(i)) {
Integer to = dg.getOpposite(i, edge);
if (list.contains(to)) {
result.addEdge(edge, i, to);
}
}
}
return result;
}
示例3: convert
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
/**
* Creates a tree using random, unique URIs instead of actual vertices and
* nodes. The lookup maps are populated with the conversions. NOTE: the Tree
* can contain duplicates in the sense that different URIs might map to the
* same vertex/edge.
*
* @param graph the graph to convert
* @param root the root of the tree
* @param vlookup a (usually empty) map that will be populated with the
* uri-to-vertex lookup
* @param elookup a (usually empty) map that will be populated with the
* uri-to-edge lookup
* @return a valid tree, no matter what
*/
public Tree<URI, URI> convert( DirectedGraph<V, E> graph,
V root, Map<URI, V> vlookup, Map<URI, E> elookup ) {
DelegateTree<URI, URI> tree = new DelegateTree<>();
Map<V, URI> revlkp = new HashMap<>();
ArrayDeque<V> deque = new ArrayDeque<>();
Queue<V> todo = ( Search.DFS == method
? Collections.asLifoQueue( deque )
: deque );
URI rootu = Utility.getUniqueUri();
vlookup.put( rootu, root );
revlkp.put( root, rootu );
tree.setRoot( rootu );
// avoid cycles in the graph
Set<E> edgesToSkip = new HashSet<>();
todo.add( root );
while ( !todo.isEmpty() ) {
V v = todo.poll();
URI srcuri = revlkp.get( v );
// once we visit a node, we can never end
// up there again, or we're not acyclic
edgesToSkip.addAll( graph.getInEdges( v ) );
Set<E> outgoings = new HashSet<>( graph.getOutEdges( v ) );
outgoings.removeAll( edgesToSkip );
for ( E e : outgoings ) {
V child = graph.getOpposite( v, e );
URI edgeuri = Utility.getUniqueUri();
URI tgturi = Utility.getUniqueUri();
elookup.put( edgeuri, e );
vlookup.put( tgturi, child );
revlkp.put( child, tgturi );
tree.addChild( edgeuri, srcuri, tgturi );
todo.add( child );
}
}
return tree;
}
示例4: iconvert
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
private Tree<V, E> iconvert( DirectedGraph<V, E> graph, V root,
boolean throwExceptions ) throws TreeConversionException {
ArrayDeque<V> deque = new ArrayDeque<>();
Queue<V> todo = ( Search.DFS == method
? Collections.asLifoQueue( deque )
: deque );
DelegateTree<V, E> tree = new DelegateTree<>();
tree.setRoot( root );
todo.add( root );
// avoid cycles in the graph
Set<E> edgesToSkip = new HashSet<>();
while ( !todo.isEmpty() ) {
V v = todo.poll();
// once we visit a node, we can never end
// up there again, or we're not acyclic
edgesToSkip.addAll( graph.getInEdges( v ) );
Set<E> outgoings = new HashSet<>( graph.getOutEdges( v ) );
outgoings.removeAll( edgesToSkip );
for ( E e : outgoings ) {
V child = graph.getOpposite( v, e );
if ( tree.containsVertex( child ) ) {
if ( throwExceptions ) {
throw new TreeConversionException();
}
}
else {
tree.addChild( e, v, child );
todo.add( child );
}
}
}
return tree;
}