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


Java SimpleDirectedGraph.incomingEdgesOf方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:28,代码来源:AbstractOrgClosureTest.java

示例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;
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:42,代码来源:HierUtil.java

示例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;
}
 
开发者ID:apache,项目名称:directory-fortress-core,代码行数:34,代码来源:HierUtil.java


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