本文整理汇总了Java中org.jgrapht.graph.SimpleDirectedGraph.incomingEdgesOf方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleDirectedGraph.incomingEdgesOf方法的具体用法?Java SimpleDirectedGraph.incomingEdgesOf怎么用?Java SimpleDirectedGraph.incomingEdgesOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgrapht.graph.SimpleDirectedGraph
的用法示例。
在下文中一共展示了SimpleDirectedGraph.incomingEdgesOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkChildrenSets
import org.jgrapht.graph.SimpleDirectedGraph; //导入方法依赖的package包/类
private void checkChildrenSets(Set<String> oidsToCheck) {
SimpleDirectedGraph<String,DefaultEdge> tc = (SimpleDirectedGraph) orgGraph.clone();
TransitiveClosure.INSTANCE.closeSimpleDirectedGraph(tc);
for (String subroot : oidsToCheck) {
LOGGER.info("Checking descendants of {}", subroot);
Set<String> expectedChildren = new HashSet<>();
for (DefaultEdge edge : tc.incomingEdgesOf(subroot)) {
expectedChildren.add(tc.getEdgeSource(edge));
}
expectedChildren.add(subroot);
LOGGER.trace("Expected children: {}", expectedChildren);
Set<String> actualChildren = getActualChildrenOf(subroot);
LOGGER.trace("Actual children: {}", actualChildren);
Set<String> expectedMinusActual = new HashSet<>(expectedChildren);
expectedMinusActual.removeAll(actualChildren);
if (!expectedMinusActual.isEmpty()) {
System.out.println("Expected-Actual = " + expectedMinusActual);
}
Set<String> actualMinusExpected = new HashSet<>(actualChildren);
actualMinusExpected.removeAll(expectedChildren);
if (!actualMinusExpected.isEmpty()) {
System.out.println("Actual-Expected = " + actualMinusExpected);
}
assertEquals("Incorrect children for " + subroot, expectedChildren, actualChildren);
}
}
示例2: getDescendants
import org.jgrapht.graph.SimpleDirectedGraph; //导入方法依赖的package包/类
/**
* Utility function recursively traverses a given digraph to build a set of all descendants names.
*
* @param vertex contains the position of the cursor for traversal of graph.
* @param graph contains a reference to simple digraph {@code org.jgrapht.graph.SimpleDirectedGraph}.
* @param descendants contains the result set of names of all descendants of node.
* @return value contains the vertex of current position.
*/
private static String getDescendants( Map<String, String> vertex, SimpleDirectedGraph<String, Relationship> graph,
Set<String> descendants )
{
String v = vertex.get( VERTEX );
if ( v == null )
{
// vertex is null
return null;
}
else if ( graph == null )
{
// graph is null
return null;
}
LOG.debug( "getDescendants [{}]", v);
Set<Relationship> edges;
try
{
edges = graph.incomingEdgesOf( v );
}
catch ( java.lang.IllegalArgumentException iae )
{
// vertex is leaf.
return null;
}
for ( Relationship edge : edges )
{
vertex.put( VERTEX, edge.getChild() );
descendants.add( edge.getChild() );
v = getDescendants( vertex, graph, descendants );
}
return v;
}
示例3: getChildren
import org.jgrapht.graph.SimpleDirectedGraph; //导入方法依赖的package包/类
/**
* Utility function returns a set of all children (direct descendant) names.
*
* @param vertex contains the position of the cursor for traversal of graph.
* @param graph contains a reference to simple digraph {@code org.jgrapht.graph.SimpleDirectedGraph}.
* @return value contains the vertex of current position.
*/
static Set<String> getChildren( String vertex, SimpleDirectedGraph<String, Relationship> graph )
{
Set<String> descendants = new HashSet<>();
if ( graph == null )
{
// graph is null
return null;
}
LOG.debug( "getChildren [{}]", vertex );
Set<Relationship> edges;
try
{
edges = graph.incomingEdgesOf( vertex );
}
catch ( java.lang.IllegalArgumentException iae )
{
// vertex is leaf.
return null;
}
for ( Relationship edge : edges )
{
descendants.add( edge.getChild() );
}
return descendants;
}