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


Java DirectedPseudograph.vertexSet方法代码示例

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


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

示例1: neighbors

import org.jgrapht.graph.DirectedPseudograph; //导入方法依赖的package包/类
private Set<Edge> neighbors(DirectedPseudograph<Resource, Edge> candidate,
        DirectedPseudograph<Resource, Edge> fullGraph) {
    Set<Edge> result = new HashSet<>();
    for (Resource node : candidate.vertexSet())
        for (Edge e : fullGraph.outgoingEdgesOf(node)) {
            if (candidate.containsEdge(e))
                continue;
            result.add(e);
        }
    return result;
}
 
开发者ID:DrDub,项目名称:Alusivo,代码行数:12,代码来源:GraphAlgorithm.java

示例2: GGraph

import org.jgrapht.graph.DirectedPseudograph; //导入方法依赖的package包/类
public GGraph(DirectedPseudograph<GVertex, GEdge> gGraph) {
    this.gGraph = gGraph;
    vertexMap = new HashMap<>();
    for(GVertex gVertex : gGraph.vertexSet()) {
        vertexMap.put(gVertex.getName(),gVertex);
    }
}
 
开发者ID:bergeoisie,项目名称:jtextiles,代码行数:8,代码来源:GGraph.java

示例3: findGraph

import org.jgrapht.graph.DirectedPseudograph; //导入方法依赖的package包/类
private Pair<DirectedPseudograph<Resource, Edge>, Double>
    findGraph(URI referent,
              DirectedPseudograph<Resource, Edge> fullGraph, DirectedPseudograph<Resource, Edge> bestGraph,
              double bestGraphCost, DirectedPseudograph<Resource, Edge> candidate, long startTime,
              final Map<String, Integer>mappedOrder)
        throws ReferringExpressionException {
    double candidateCost = cost(candidate);
    if (bestGraph != null && bestGraphCost <= candidateCost)
        return Pair.of(bestGraph, bestGraphCost);

    List<Resource> distractors = new ArrayList<Resource>(fullGraph.vertexSet().size());
    for (Resource v : fullGraph.vertexSet()) {
        if (System.currentTimeMillis() - startTime > maxTime)
            throw new ReferringExpressionException("Time-out");
        if (v != referent && matchGraphs(referent, candidate, v, fullGraph, startTime))
            distractors.add(v);
    }

    if (distractors.isEmpty())
        return Pair.of(candidate, candidateCost);

    Collection<Edge>neighbors = neighbors(candidate, fullGraph);
    if(mappedOrder != null){
        List<Edge>toSort = new ArrayList<Edge>(neighbors);

        Collections.sort(toSort, new Comparator<Edge>() {
                public int compare(Edge e1, Edge e2) {
                    Integer m1 = mappedOrder.get(e1.getURI().getLocalName());
                    Integer m2 = mappedOrder.get(e2.getURI().getLocalName());
                    if (m1 != null && m2 != null)
                        return m1.compareTo(m2);
                    if (m1 != null)
                        return -1;
                    if (m2 != null)
                        return 1;
                    return e1.getURI().toString().compareTo(e2.getURI().toString());
                }
            });
        neighbors = toSort;
    }
    for (Edge e : neighbors) {
        if (System.currentTimeMillis() - startTime > maxTime)
            throw new ReferringExpressionException("Time-out");

        @SuppressWarnings("unchecked")
        DirectedPseudograph<Resource, Edge> newCandidate = (DirectedPseudograph<Resource, Edge>) candidate.clone();
        Resource source = fullGraph.getEdgeSource(e);
        Resource target = fullGraph.getEdgeTarget(e);
        if (!newCandidate.vertexSet().contains(source))
            // odd, this shouldn't always be the case?
            newCandidate.addVertex(source);
        if (!newCandidate.vertexSet().contains(target))
            newCandidate.addVertex(target);
        newCandidate.addEdge(fullGraph.getEdgeSource(e), fullGraph.getEdgeTarget(e), e);
        Pair<DirectedPseudograph<Resource, Edge>, Double> p =
            findGraph(referent, fullGraph, bestGraph,
                      bestGraphCost, newCandidate, startTime, mappedOrder);
        if (bestGraph == null || p.getRight() <= bestGraphCost) {
            bestGraph = p.getLeft();
            bestGraphCost = p.getRight();
        }
    }

    return Pair.of(bestGraph, bestGraphCost);
}
 
开发者ID:DrDub,项目名称:Alusivo,代码行数:66,代码来源:GraphAlgorithm.java

示例4: matchHelper

import org.jgrapht.graph.DirectedPseudograph; //导入方法依赖的package包/类
private boolean matchHelper(Map<Resource, Resource> bijection, // pi
        Set<Resource> neighbors, // Y
        DirectedPseudograph<Resource, Edge> fullGraph, // G
        DirectedPseudograph<Resource, Edge> candidate, // H
        long startTime) throws ReferringExpressionException {

    if (bijection.keySet().size() == candidate.vertexSet().size()) {
        return true;
    }
    if (neighbors.isEmpty()){
        return false;
    }

    if (System.currentTimeMillis() - startTime > maxTime)
        throw new ReferringExpressionException("Time-out");

    for (Resource toMap : neighbors) { // y
        if (bijection.containsKey(toMap))
            continue;
        // find valid matches Z
        for (Resource extension : fullGraph.vertexSet()) { // z
            if (bijection.values().contains(extension) || bijection.keySet().contains(extension))
                continue;
            if (!containedPropertiesInSubgraph(toMap, candidate, extension, fullGraph))
                continue;
            Set<Resource> toCheck = neighbors(candidate, toMap);
            toCheck.retainAll(bijection.keySet());
            boolean good = true;
            for (Resource other : toCheck) { // h
                // (toMap -> other) y->h
                Set<Edge> outgoing = candidate.getAllEdges(toMap, other);
                if (!fullGraph.getAllEdges(extension, bijection.get(other)).containsAll(outgoing)) {
                    good = false;
                    break;
                }
                // (other -> toMap) y->h
                Set<Edge> incoming = candidate.getAllEdges(other, toMap);
                if (!fullGraph.getAllEdges(bijection.get(other), extension).containsAll(incoming)) {
                    good = false;
                    break;
                }
            }
            if (!good)
                continue;
            Map<Resource, Resource> bijectionRec = new HashMap<>();
            bijectionRec.putAll(bijection);
            bijectionRec.put(toMap, extension);
            Set<Resource> neighborsRec = new HashSet<Resource>(neighbors);
            neighborsRec.remove(toMap); // not in Figure 8
            if (matchHelper(bijectionRec, neighborsRec, fullGraph, candidate, startTime))
                return true;
        }

    }
    return false;
}
 
开发者ID:DrDub,项目名称:Alusivo,代码行数:57,代码来源:GraphAlgorithm.java


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