當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultEdge類代碼示例

本文整理匯總了Java中org.jgrapht.graph.DefaultEdge的典型用法代碼示例。如果您正苦於以下問題:Java DefaultEdge類的具體用法?Java DefaultEdge怎麽用?Java DefaultEdge使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultEdge類屬於org.jgrapht.graph包,在下文中一共展示了DefaultEdge類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addEdgesForEquivalenceClass

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
private void addEdgesForEquivalenceClass(String constant, FormulaVariable variable, String operator,
        IFormula formula, UndirectedGraph<FormulaGraphVertex, DefaultEdge> graph, Map<FormulaVariable, FormulaGraphVertex> vertexMap) {
    VariableEquivalenceClass equivalenceClass = DependencyUtility.findEquivalenceClassForVariable(variable, formula.getLocalVariableEquivalenceClasses());
    if (logger.isDebugEnabled()) logger.debug("Adding edges for equivalence class " + equivalenceClass);
    for (FormulaVariable otherVariable : equivalenceClass.getVariables()) {
        if (otherVariable.equals(variable)) {
            continue;
        }
        if (existComparison(otherVariable, constant, formula)) {
            continue;
        }
        Expression expression = new Expression(otherVariable.getId() + operator + constant);
        ComparisonAtom virtualComparisonAtom = new ComparisonAtom(formula, expression, otherVariable.getId(), null, null, constant, operator);
        virtualComparisonAtom.addVariable(otherVariable);
        FormulaGraphVertex virtualComparisonVertex = new FormulaGraphVertex(virtualComparisonAtom);
        virtualComparisonVertex.setVirtual(true);
        graph.addVertex(virtualComparisonVertex);
        FormulaGraphVertex variableVertex = vertexMap.get(otherVariable);
        graph.addEdge(virtualComparisonVertex, variableVertex);
        createConstantVertex(constant, virtualComparisonVertex, graph);
    }
}
 
開發者ID:dbunibas,項目名稱:BART,代碼行數:23,代碼來源:FindFormulaWithAdornments.java

示例2: testAllMissingEntitiesAreExpected

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
private boolean testAllMissingEntitiesAreExpected(final DefinitionModel definition, final Consumer<ErrorModel> errorListner,
    final Map<String, ExpectedModel> missing, final DirectedGraph<BaseInstanceModel, DefaultEdge> entityGraph) {
  //check computed expected are actually expected
  boolean errored = false;
  List<String> expectedMissing = definition.getExpectedDefinitions().stream().map(em -> em.getIdentity())
      .collect(Collectors.toList());
  for (ExpectedModel expected : missing.values()) {
    if (!expectedMissing.contains(expected.getIdentity())) {
      List<AbstractModel> dependsOnMissing = Stream.concat(
          Stream.of(definition), 
          entityGraph.incomingEdgesOf(expected).stream().map(edge -> entityGraph.getEdgeSource(edge))
            .filter(m -> m.getSourceElement().isPresent()))
          .collect(Collectors.toList());
      errored = true;
      errorListner.accept(new ErrorModel(ErrorType.MISSING_BEAN_DEFINITIONS, Arrays.asList(expected), dependsOnMissing));
    } else {
      definition.addComputedExpected(expected);
    }
  }
  return errored;
}
 
開發者ID:salesforce,項目名稱:AptSpring,代碼行數:22,代碼來源:DefinitionContentInspector.java

示例3: pathsToParents

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
@Override
public Collection<Call> pathsToParents(MethodGraph element) {
  Collection<Call> paths = new HashSet<>();
    logger.debug("Finding path to parents for: {} ", element);
  if (!directedGraph.containsVertex(element)) {
    logger.warn("Graph does not contain vertex: {} . Returning empty collection.", element);
    return paths;
  }
  Set<DefaultEdge> incomingEdges = directedGraph.incomingEdgesOf(element);
  if (incomingEdges.isEmpty()) {
    Call lonelyCall = new Call(element, null);
    paths.add(lonelyCall);
    return paths;
  }
  for (DefaultEdge incomingEdge : incomingEdges) {
    MethodGraph father = directedGraph.getEdgeSource(incomingEdge);
    logger.debug("Finding path to parents, element={}, father={} . About to find paths from father", element, father);
    Call call = new Call(father, element);
    paths.add(call);
    paths.addAll(pathsToParents(father));
  }
  return paths;
}
 
開發者ID:fergarrui,項目名稱:custom-bytecode-analyzer,代碼行數:24,代碼來源:InvocationGraphImpl.java

示例4: nonPlanarRandomGraphStructure

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
/**
 * Creates a naive, random, not necessarily planar graph
 */
@Deprecated
public static UndirectedGraph<RegionSetup, DefaultEdge> nonPlanarRandomGraphStructure(
        final double populationPerRegionMean,
        final double populationStandardDeviation,
        UniformDistributionRNG rng,
        IntegerInterval numberOfRegionsInterval,
        IntegerInterval averageAdjacenciesPerRegionInterval
) {
    int numberOfRegions = rng.nextInt(numberOfRegionsInterval);
    int numberOfAdjacencies = rng.nextInt(averageAdjacenciesPerRegionInterval) * numberOfRegions;
    RandomGraphGenerator<RegionSetup, DefaultEdge> randomGraphGenerator = new RandomGraphGenerator<>(
            numberOfRegions, numberOfAdjacencies, rng.nextLong());
    SimpleGraph<RegionSetup, DefaultEdge> targetGraph = new SimpleGraph<>(DefaultEdge.class);
    VertexFactory<RegionSetup> vertexFactory = () -> new RegionSetup(populationPerRegionMean, populationStandardDeviation, "randomly created");
    randomGraphGenerator.generateGraph(targetGraph, vertexFactory, null);
    return targetGraph;
}
 
開發者ID:spectrumauctions,項目名稱:sats-core,代碼行數:21,代碼來源:MRVMWorldSetup.java

示例5: deserialize

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
@Override
public UnmodifiableUndirectedGraph<MRVMRegionsMap.Region, DefaultEdge> deserialize(JsonElement json, Type typeOfT,
                                                                                   JsonDeserializationContext context) throws JsonParseException {

    JsonArray jsonArray = json.getAsJsonArray();
    Set<SerializedRegion> serializedRegions = new HashSet<>();
    Map<Integer, MRVMRegionsMap.Region> regionsById = new HashMap<>();
    SimpleGraph<MRVMRegionsMap.Region, DefaultEdge> graph = new SimpleGraph<>(DefaultEdge.class);
    for (int i = 0; i < jsonArray.size(); i++) {
        JsonElement regionElement = jsonArray.get(i);
        SerializedRegion r = context.deserialize(regionElement, SerializedRegion.class);
        serializedRegions.add(r);
        regionsById.put(r.getNode().getId(), r.getNode());
        graph.addVertex(r.getNode());

    }
    for (SerializedRegion serializedRegion : serializedRegions) {
        Set<Integer> neighbors = serializedRegion.getNeighbors();
        for (Integer neighborId : neighbors) {
            graph.addEdge(serializedRegion.getNode(), regionsById.get(neighborId));
        }
    }

    return new UnmodifiableUndirectedGraph<>(graph);
}
 
開發者ID:spectrumauctions,項目名稱:sats-core,代碼行數:26,代碼來源:UndirectedGraphAdapter.java

示例6: getConnectedTo

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
@Override
public Object[] getConnectedTo(Object entity) {
    if (entity instanceof PgStatement){
        DirectedGraph<PgStatement, DefaultEdge> currentGraph = depRes.getOldGraph();
        if (currentGraph != null){
            List<PgStatement> connected = new ArrayList<>();
            for (DefaultEdge e : currentGraph.outgoingEdgesOf((PgStatement)entity)){
                PgStatement connectedVertex = currentGraph.getEdgeTarget(e);
                if (!(connectedVertex instanceof PgColumn)) {
                    connected.add(connectedVertex);
                }
            }
            return connected.toArray();
        }
    }
    return null;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:18,代碼來源:DepcyGraphView.java

示例7: handleChanges

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
private MutableList<ExecuteChangeCommand> handleChanges(MutableCollection<Change> fromSourceList) {
    final MutableList<ExecuteChangeCommand> commands = Lists.mutable.empty();

    DirectedGraph<Change, DefaultEdge> graph = enricher.createDependencyGraph(fromSourceList, false);

    if (graph != null) {
        ConnectivityInspector<Change, DefaultEdge> connectivityInspector
                = new ConnectivityInspector<Change, DefaultEdge>(graph);
        for (Set<Change> connectedSet : connectivityInspector.connectedSets()) {
            // once we have a connectedSet, sort within those changes to ensure that we still sort them in the
            // right order (i.e. via topological sort)
            ImmutableList<Change> fullChanges = sorter.sortChanges(graph, SetAdapter.adapt(connectedSet), SortableDependency.GRAPH_SORTER_COMPARATOR);
            commands.add(changeCommandFactory.createDeployCommand(new GroupChange(fullChanges)));
        }
    }

    return commands;
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:19,代碼來源:StaticDataChangeTypeCommandCalculator.java

示例8: sortChanges

import org.jgrapht.graph.DefaultEdge; //導入依賴的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

示例9: testSchemaObjectDependencies

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
/**
 * The test data in this class is all written w/ case-sensitivy as the default.
 * If we pass caseInsensitive == true, then we enable that mode in the graph enricher and tweak the object names
 * a bit so that we can verify that the resolution works either way.
 */
public void testSchemaObjectDependencies(boolean caseInsensitive) {
    this.enricher = new GraphEnricherImpl(caseInsensitive ? StringFunctions.toUpperCase() : Functions.getStringPassThru());

    SortableDependencyGroup sch1Obj1 = newChange(schema1, type1, "obj1", Sets.immutable.with("obj3", schema2 + ".obj2"));
    SortableDependencyGroup sch1Obj2 = newChange(schema1, type2, "obj2", Sets.immutable.<String>with());
    // change the case of the object name to ensure others can still point to it
    SortableDependencyGroup sch1Obj3 = newChange(schema1, type1, caseInsensitive ? "obj3".toUpperCase() : "obj3", Sets.immutable.with("obj2"));
    // change the case of the dependency name to ensure that it can point to others
    SortableDependencyGroup sch2Obj1 = newChange(schema2, type1, "obj1", Sets.immutable.with(caseInsensitive ? "obj2".toUpperCase() : "obj2"));
    SortableDependencyGroup sch2Obj2 = newChange(schema2, type2, "obj2", Sets.immutable.with(schema1 + ".obj3"));

    DirectedGraph<SortableDependencyGroup, DefaultEdge> sortGraph = enricher.createDependencyGraph(Lists.mutable.with(
            sch1Obj1, sch1Obj2, sch1Obj3, sch2Obj1, sch2Obj2), false);

    validateChange(sortGraph, sch1Obj1, Sets.immutable.with(sch1Obj3, sch2Obj2), Sets.immutable.<SortableDependencyGroup>with());
    validateChange(sortGraph, sch1Obj2, Sets.immutable.<SortableDependencyGroup>with(), Sets.immutable.with(sch1Obj3));
    validateChange(sortGraph, sch1Obj3, Sets.immutable.with(sch1Obj2), Sets.immutable.with(sch1Obj1, sch2Obj2));
    validateChange(sortGraph, sch2Obj1, Sets.immutable.with(sch2Obj2), Sets.immutable.<SortableDependencyGroup>with());
    validateChange(sortGraph, sch2Obj2, Sets.immutable.with(sch1Obj3), Sets.immutable.with(sch1Obj1, sch2Obj1));
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:26,代碼來源:GraphEnricherImplTest.java

示例10: testGetChangesCaseInsensitive

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
@Test
public void testGetChangesCaseInsensitive() {
    this.enricher = new GraphEnricherImpl(StringFunctions.toUpperCase());
    String schema1 = "schema1";
    String schema2 = "schema2";
    String type1 = "type1";

    SortableDependencyGroup sp1 = newChange(schema1, type1, "SP1", "n/a", 0, Sets.immutable.with("sp2"));
    SortableDependencyGroup sp2 = newChange(schema1, type1, "SP2", Sets.immutable.<String>with());
    SortableDependencyGroup sp3 = newChange(schema1, type1, "SP3", Sets.immutable.with("sp1", "sp2"));
    SortableDependencyGroup spA = newChange(schema1, type1, "SPA", Sets.immutable.with("sp3"));
    SortableDependencyGroup sp1Schema2 = newChange(schema2, type1, "sp1", "n/a", 0, Sets.immutable.with("sp2", schema1 + ".sp3"));
    SortableDependencyGroup sp2Schema2 = newChange(schema2, type1, "sP2", "n/a", 0, Sets.immutable.<String>with());

    DirectedGraph<SortableDependencyGroup, DefaultEdge> sortGraph = enricher.createDependencyGraph(Lists.mutable.with(
            sp1, sp2, sp3, spA, sp1Schema2, sp2Schema2), false);

    validateChange(sortGraph, sp1, Sets.immutable.with(sp2), Sets.immutable.with(sp3));
    validateChange(sortGraph, sp2, Sets.immutable.<SortableDependencyGroup>with(), Sets.immutable.with(sp1, sp3));
    validateChange(sortGraph, sp3, Sets.immutable.with(sp1, sp2), Sets.immutable.with(spA, sp1Schema2));
    validateChange(sortGraph, spA, Sets.immutable.with(sp3), Sets.immutable.<SortableDependencyGroup>with());
    validateChange(sortGraph, sp1Schema2, Sets.immutable.with(sp2Schema2, sp3), Sets.immutable.<SortableDependencyGroup>with());
    validateChange(sortGraph, sp2Schema2, Sets.immutable.<SortableDependencyGroup>with(), Sets.immutable.with(sp1Schema2));
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:25,代碼來源:GraphEnricherImplTest.java

示例11: assertHasSingleCronRoot

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
private void assertHasSingleCronRoot(DirectedAcyclicGraph<NameAndGroup, DefaultEdge> graph) {
    Iterator<NameAndGroup> itr = graph.iterator();
    NameAndGroup root = null;
    while (itr.hasNext()) {
        NameAndGroup cur = itr.next();
        if(!isRoot(graph, cur)) {
            continue;
        }

        if(root != null) {
            throw new CronyxException(String.format("Graph has at least 2 roots: %s, %s", root, cur));
        }

        if(!isCron(cur)) {
            throw new CronyxException("Found a root that is not a cron trigger: " + cur);
        }

        root = cur;
    }

    if(root == null) {
        throw new CronyxException("Didn't find a root in the graph!");
    }
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:25,代碼來源:StdNameAndGroupGraphValidator.java

示例12: modify

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void modify(JCas jcas) throws AnalysisEngineProcessException {
  Collection<CandidateAnswerVariant> cavs = TypeUtil.getCandidateAnswerVariants(jcas);
  UndirectedGraph<Object, DefaultEdge> graph = new SimpleGraph<>(DefaultEdge.class);
  cavs.forEach(cav -> {
    graph.addVertex(cav);
    for (String name : TypeUtil.getCandidateAnswerVariantNames(cav)) {
      graph.addVertex(name);
      graph.addEdge(cav, name);
    }
  } );
  ConnectivityInspector<Object, DefaultEdge> ci = new ConnectivityInspector<>(graph);
  ci.connectedSets().stream().map(subgraph -> {
    List<CandidateAnswerVariant> subCavs = subgraph.stream()
            .filter(CandidateAnswerVariant.class::isInstance)
            .map(CandidateAnswerVariant.class::cast).collect(toList());
    return TypeFactory.createAnswer(jcas, TypeConstants.SCORE_UNKNOWN, subCavs);
  } ).forEach(Answer::addToIndexes);
}
 
開發者ID:oaqa,項目名稱:bioasq,代碼行數:21,代碼來源:CavMerger.java

示例13: addVertexAndEdge

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
private void addVertexAndEdge(Intent<? extends Resolution> fromIntent,
		Intent<? extends Resolution> toIntent,
		DirectedAcyclicGraph<Handler<? extends Intent<? extends Resolution>>, DefaultEdge> dag)
{
	Handler<? extends Intent<? extends Resolution>> toHandler = handlerFactory.build(toIntent);
	dag.addVertex(toHandler);

	try
	{
		dag.addDagEdge(handlerFactory.build(fromIntent), toHandler);
	}
	catch (CycleFoundException e)
	{
		throw new RuntimeException("Cycle found building allegedly acyclical graph", e);
	}
}
 
開發者ID:EngineerBetter,項目名稱:cf-converger,代碼行數:17,代碼來源:HardcodedOrderedHandlerBuilder.java

示例14: findParentNodes

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
public List<String> findParentNodes(String nodeID){
	
List<String> parentNodes = new LinkedList<>();

       //Get incoming edges of given service
       Set<DefaultEdge> incomingEdges = graphComposition.incomingEdgesOf(nodeID);
	
//Put the source nodes of the incomingEdges in the list of parentNodes
Iterator it = incomingEdges.iterator();
while (it.hasNext()) {
           String sourceNode = graphComposition.getEdgeSource((DefaultEdge) it.next());
           parentNodes.add(sourceNode);
}
	
return parentNodes;
   }
 
開發者ID:usplssb,項目名稱:SemanticSCo,代碼行數:17,代碼來源:ServiceComposer.java

示例15: getParameterOrdering

import org.jgrapht.graph.DefaultEdge; //導入依賴的package包/類
private List<Field> getParameterOrdering(DirectedGraph<Field, DefaultEdge> dependencyGraph) {
	CycleDetector<Field, DefaultEdge> cycleDetector = new CycleDetector<Field, DefaultEdge>(dependencyGraph);
	if (cycleDetector.detectCycles()) {
		throw new RuntimeException("Cyclic dependency detected!");
	} else {
		TopologicalOrderIterator<Field, DefaultEdge> orderIterator;
		Field f;
		orderIterator = new TopologicalOrderIterator<Field, DefaultEdge>(dependencyGraph);
	
		List<Field> output = new ArrayList<>(dependencyGraph.vertexSet().size());

		while (orderIterator.hasNext()) {
			f = orderIterator.next();
			output.add(f);
		}

		return output;
	}
}
 
開發者ID:isse-augsburg,項目名稱:minibrass,代碼行數:20,代碼來源:ConfigurationProvider.java


注:本文中的org.jgrapht.graph.DefaultEdge類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。