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


Java DirectedGraph.vertexSet方法代码示例

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


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

示例1: intersect

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
@Override
public DirectedGraph<Node, Triple> intersect(DirectedGraph<Node, Triple> baseGraph, DirectedGraph<Node, Triple> removalGraph) {
    DirectedGraph<Node, Triple> result = new DirectedSubgraph<>(baseGraph, removalGraph.vertexSet(), removalGraph.edgeSet());

    //Materialize the intersection
    //DirectedGraph<Node, Triple> tmp = createNew();
    //Graphs.addGraph(tmp, result);
    //result = tmp

    return result;
}
 
开发者ID:SmartDataAnalytics,项目名称:SubgraphIsomorphismIndex,代码行数:12,代码来源:SetOpsJGraphTRdfJena.java

示例2: sortChanges

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
/**
 * Sorts the graph to provide a consistent topological ordering.
 *
 * @param graph          The input graph
 * @param subsetVertices The subset vertices of the graph we want to sort
 * @param comparator     The comparator on which to order the vertices to guarantee a consistent topological ordering
 */
public <T> ImmutableList<T> sortChanges(DirectedGraph<T, DefaultEdge> graph, RichIterable<T> subsetVertices, Comparator<? super T> comparator) {
    if (subsetVertices.toSet().size() != subsetVertices.size()) {
        throw new IllegalStateException("Unexpected state - have some dupe elements here: " + subsetVertices);
    }

    DirectedGraph<T, DefaultEdge> subsetGraph = new DirectedSubgraph<T, DefaultEdge>(
            graph, subsetVertices.toSet(), null);

    // At one point, we _thought_ that the DirectedSubGraph was dropping vertices that don't have edges, so we
    // manually add them back to the graph to ensure that we can still order them.
    // However, that no longer seems to be the case. We add a check here just in case this comes up again.
    if (subsetVertices.size() != subsetGraph.vertexSet().size()) {
        throw new IllegalArgumentException("This case should never happen! [subsetVertices: " + subsetVertices + ", subsetGraphVertices: " + subsetGraph.vertexSet());
    }

    return sortChanges(subsetGraph, comparator);
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:25,代码来源:GraphSorter.java

示例3: determineAndSolveConflicts

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
protected static void determineAndSolveConflicts(final PathBlockSet resultBlocks) {
    // determine conflicts
    final PathBlockSet deletedBlocks = new PathBlockSet();
    final DirectedGraph<Block, BlockConflict> blockConflictGraph = new SimpleDirectedGraph<>(BlockConflict::of);
    for (final Block block : resultBlocks.getBlocks()) {
        blockConflictGraph.addVertex(block);
    }
    for (final Block x : blockConflictGraph.vertexSet()) {
        createArcs(blockConflictGraph, resultBlocks, x);
    }
    // solve conflicts
    while (true) {
        final Optional<BlockConflict> mostUsefulConflictsFirst =
                blockConflictGraph.edgeSet().stream().max(Comparator.comparingInt(BlockConflict::getQuality));
        if (!mostUsefulConflictsFirst.isPresent()) {
            break;
        }
        final BlockConflict blockConflict = mostUsefulConflictsFirst.get();
        solveConflict(blockConflict, blockConflictGraph, resultBlocks, deletedBlocks);
    }
}
 
开发者ID:RWTH-i5-IDSG,项目名称:jamocha,代码行数:22,代码来源:PathBlocks.java

示例4: findReachableSourceAttributes

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private Set<AttributeRef> findReachableSourceAttributes(AttributeRef targetAttribute, DirectedGraph<AttributeRef, DefaultEdge> dependencyGraph) {
    Set<AttributeRef> result = new HashSet<AttributeRef>();
    for (AttributeRef attribute : dependencyGraph.vertexSet()) {
        if (!attribute.isSource()) {
            continue;
        }
        if (result.contains(attribute)) {
            continue;
        }
        List path = DijkstraShortestPath.findPathBetween(dependencyGraph, attribute, targetAttribute);
        if (path != null) {
            result.add(attribute);
        }
    }
    return result;
}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:17,代码来源:CheckConflicts.java

示例5: collapseGraph

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public DirectedGraph<FunctionVertex, CallEdge> collapseGraph() {
    DirectedGraph<FunctionVertex, CallEdge> g = cloneGraph(graph);
    List<FunctionVertex> vToRemove = new ArrayList<>();

    for (int i = 0; i < 10; i++) {
        vToRemove.clear();
        /* remove all vertrtices with zero stack and no childs */
        for (FunctionVertex fn : g.vertexSet()) {
            Set<CallEdge> oe = g.outgoingEdgesOf(fn);
            if (oe.isEmpty() && fn.stack == 0) {
                vToRemove.add(fn);
            }
        }
        g.removeAllVertices(vToRemove);
    }

    for (int i = 0; i < 1000; i++) {
        traverseMaxStack(g);
    }
    
    return g;
}
 
开发者ID:j123b567,项目名称:stack-usage,代码行数:23,代码来源:CallGraph.java

示例6: createPackageVerticesMap

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private Map<String, Set<InfoVertex<T, C>>> createPackageVerticesMap(
		DirectedGraph<InfoVertex<T, C>, DependencyEdge> graph) {
	final Map<String, Set<InfoVertex<T, C>>> packageVerticesMap = new HashMap<String, Set<InfoVertex<T, C>>>();
	for (InfoVertex<T, C> vertex : graph.vertexSet()) {
		final MPackageInfo packageInfo = vertex.getPackageInfo();

		if (packageInfo != null) {
			Set<InfoVertex<T, C>> packageVertices = packageVerticesMap
					.get(packageInfo.getPackageName());
			if (packageVertices == null) {
				packageVertices = new HashSet<InfoVertex<T, C>>();
				packageVerticesMap.put(packageInfo.getPackageName(),
						packageVertices);
			}
			packageVertices.add(vertex);
		}
	}
	return packageVerticesMap;
}
 
开发者ID:highsource,项目名称:jsonix-schema-compiler,代码行数:20,代码来源:ModelInfoGraphAnalyzer.java

示例7: SSA

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected SSA(DirectedGraph<V, E> graph, Dominators<V, E> dom) {
    if (!(graph instanceof CFG)) {
        throw new IllegalArgumentException();
    }
    this.cfg = (CFG) graph;
    this.dom = dom;
    this.domFrontier = dom.getDF();
    this.cdgTree = new SSAGraph<>();
    for (V v : graph.vertexSet()) {
        cdgTree.addVertex(v);
    }
    for (E e : graph.edgeSet()) {
        cdgTree.addEdge(graph.getEdgeSource(e), graph.getEdgeTarget(e));
    }
    this.cdgBlockTree = new SSABlockTree<>(this.cdgTree, dom.getStart());
    // gather variables
    discoverVariables();
    //this.count = new int[variables.size()];
    this.count = new HashMap<>(variables.size());
    this.stack = new HashMap<>(variables.size());
    // for each variable a
    for (int i : variables) {
        //count[i] = 0;
        count.put(i, 0);
        stack.put(i, new LinkedList<Integer>());
        stack.get(i).add(0); // push 0 onto Stack[a]
    }
}
 
开发者ID:DocGerd,项目名称:DalvikSSA,代码行数:30,代码来源:SSA.java

示例8: write

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public static <V, E> void write(DirectedGraph<V, E> g, String fileName) throws FileNotFoundException {
    try (PrintWriter out = new PrintWriter(fileName)) {
        out.print("digraph \"DirectedGraph\" { \n graph [label=\"");
        out.print(g.toString());
        out.print("\", labelloc=t, concentrate=true]; ");
        out.print("center=true;fontsize=12;node [fontsize=12];edge [fontsize=12]; \n");

        for (V node : g.vertexSet()) {
            out.print("   \"");
            out.print(getId(node));
            out.print("\" ");
            out.print("[label=\"");
            out.print(node.toString());
            out.print("\" shape=\"box\" color=\"blue\" ] \n");
        }

        for (V src : g.vertexSet()) {
            for (E e : g.outgoingEdgesOf(src)) {
                V tgt = g.getEdgeTarget(e);

                out.print(" \"");
                out.print(getId(src));
                out.print("\" -> \"");
                out.print(getId(tgt));
                out.print("\" ");
                out.print("[label=\"");
                out.print(e.toString());
                out.print("\"]\n");
            }
        }

        out.print("\n}");

        out.flush();
    }
}
 
开发者ID:DocGerd,项目名称:DalvikSSA,代码行数:37,代码来源:WriteGraphToDot.java

示例9: findAttributes

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public AttributesInSameCellGroups findAttributes(DirectedGraph<AttributeRef, ExtendedEdge> dependencyGraph) {
    AttributesInSameCellGroups attributesInSameCallGroups = new AttributesInSameCellGroups();
    Set<String> pathCache = new HashSet<String>();
    for (AttributeRef attributeRef : dependencyGraph.vertexSet()) {
        Set<AttributeRef> relatedAttributes = findRelatedAttributes(attributeRef, pathCache, dependencyGraph);
        attributesInSameCallGroups.addAttribute(attributeRef, relatedAttributes);
    }
    if (logger.isDebugEnabled()) logger.debug("Map for dependency graph " + dependencyGraph + "\n:" + attributesInSameCallGroups.toString());
    return attributesInSameCallGroups;
}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:11,代码来源:FindAttributesInSameCellGroup.java

示例10: findRelatedAttributes

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private Set<AttributeRef> findRelatedAttributes(AttributeRef attribute, Set<String> pathCache, DirectedGraph<AttributeRef, ExtendedEdge> dependencyGraph) {
    //All attributes corresponding to vertices of paths that pass throught the vertex of attribute
    Set<AttributeRef> result = new HashSet<AttributeRef>();
    for (AttributeRef otherAttribute : dependencyGraph.vertexSet()) {
        if (attribute.equals(otherAttribute)) {
            result.add(otherAttribute);
            continue;
        }
        String attributePair = buildAttributePair(attribute, otherAttribute);
        if (pathCache.contains(attributePair)) {
            result.add(otherAttribute);
            continue;
        }
        List<ExtendedEdge> outPath = DijkstraShortestPath.findPathBetween(dependencyGraph, attribute, otherAttribute);
        if (logger.isDebugEnabled()) logger.debug("Finding path between " + attribute + " and " + otherAttribute);
        if (outPath != null) {
            if (logger.isDebugEnabled()) logger.debug("Path found");
            addVerticesInPath(outPath, result, pathCache, dependencyGraph);
            continue;
        }
        List<ExtendedEdge> inPath = DijkstraShortestPath.findPathBetween(dependencyGraph, otherAttribute, attribute);
        if (logger.isDebugEnabled()) logger.debug("Finding path between " + otherAttribute + " and " + attribute);
        if (inPath != null) {
            if (logger.isDebugEnabled()) logger.debug("Path found");
            addVerticesInPath(inPath, result, pathCache, dependencyGraph);
        }
    }
    return result;
}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:30,代码来源:FindAttributesInSameCellGroup.java

示例11: findReachableAttribuesOnGraph

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private Set<AttributeRef> findReachableAttribuesOnGraph(Set<AttributeRef> initialAttributes, DirectedGraph<AttributeRef, ExtendedEdge> dependencyGraph) {
    Set<AttributeRef> result = new HashSet<AttributeRef>(initialAttributes);
    for (AttributeRef attribute : dependencyGraph.vertexSet()) {
        if (result.contains(attribute)) {
            continue;
        }
        if (isReachable(attribute, initialAttributes, dependencyGraph)) {
            result.add(attribute);
        }
    }
    return result;
}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:13,代码来源:FindAttributesWithLabeledNulls.java

示例12: traverseMaxStack

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private void traverseMaxStack(DirectedGraph<FunctionVertex, CallEdge> g) {
    int maxStack, fnStack;
    for (FunctionVertex fn : g.vertexSet()) {
        Set<CallEdge> ces = g.outgoingEdgesOf(fn);
        if (ces.isEmpty()) {
            if (fn.stack >= 0) {
                fn.maxStack = fn.stack;
            } else {
                fn.maxStack = 0;
            }
            continue;
        }

        maxStack = -1;
        for (CallEdge ce : ces) {
            fnStack = g.getEdgeTarget(ce).maxStack;
            if (fnStack >= 0) {
                maxStack = Math.max(maxStack, fnStack);
            } else {
                maxStack = -1;
                break;
            }
        }
        if (maxStack >= 0) {
            if (isRecursive(fn)) {
            } else {
                fn.maxStack = maxStack + fn.stack;
            }
        } else if (isRecursive(fn)) {
            fn.maxStack = fn.stack;
        }
    }
}
 
开发者ID:j123b567,项目名称:stack-usage,代码行数:34,代码来源:CallGraph.java

示例13: cloneGraph

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
private static DirectedGraph<FunctionVertex, CallEdge> cloneGraph(DirectedGraph<FunctionVertex, CallEdge> g) {
    DirectedGraph<FunctionVertex, CallEdge> result;
    result = new DefaultDirectedGraph<>(CallEdge.class);

    List<FunctionVertex> list = new ArrayList<>();

    for (FunctionVertex v : g.vertexSet()) {
        FunctionVertex v2 = new FunctionVertex();
        v2.clone(v);
        list.add(v2);
        result.addVertex(v2);
    }

    list.indexOf(g);
    FunctionVertex src;
    FunctionVertex dst;
    for (CallEdge e : g.edgeSet()) {
        src = g.getEdgeSource(e);
        dst = g.getEdgeTarget(e);

        /* get clonned vertex */
        src = list.get(list.indexOf(src));
        dst = list.get(list.indexOf(dst));

        result.addEdge(src, dst, new CallEdge(e.type));
    }

    return result;
}
 
开发者ID:j123b567,项目名称:stack-usage,代码行数:30,代码来源:CallGraph.java

示例14: NetworkFlow

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public NetworkFlow(DirectedGraph<V, E> graph) {
	// init the flow graph
	this.graph = graph;
	this.vertices = graph.vertexSet();
	this.numOfEdges = graph.edgeSet().size();
	this.maximumFlow = new HashMap<E, Double>();
}
 
开发者ID:yubinbai,项目名称:javatemplates,代码行数:8,代码来源:NetworkFlow.java

示例15: LinearProgrammingMaxFlow

import org.jgrapht.DirectedGraph; //导入方法依赖的package包/类
public LinearProgrammingMaxFlow(DirectedGraph<V, E> graph) {

		this.graph = graph;
		this.vertices = graph.vertexSet();
		this.edgesIndex = new ArrayList<E>();
		this.numOfEdges = graph.edgeSet().size();
		this.maximumFlow = new HashMap<E, Double>();
	}
 
开发者ID:yubinbai,项目名称:javatemplates,代码行数:9,代码来源:LinearProgrammingMaxFlow.java


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