protected void registerNode(Node n) { _graph.addVertex(n); if(n.stateInfo!=null) { String id = n.stateInfo.id; if(!_colocate.containsKey(id)) { _colocate.put(id, new ArrayList()); } _colocate.get(id).add(n); } }
graph.removeEdge(e); PartitionNode pNode = makeIdentityPartition(e.source); graph.addVertex(pNode); graph.addEdge(e.source, pNode, new IndexedEdge(e.source, pNode, 0)); graph.addEdge(pNode, e.target, new IndexedEdge(pNode, e.target, e.index)); graph.removeVertex(n); graph.addVertex(idNode); graph.addVertex(newPartitionNode); addEdge(graph, parentNode, idNode, 0); addEdge(graph, idNode, newPartitionNode, 0);
@Override public boolean addVertex(V v) { return m_graph.addVertex(v); }
protected void registerNode(Node n) { _graph.addVertex(n); if(n.stateInfo!=null) { String id = n.stateInfo.id; if(!_colocate.containsKey(id)) { _colocate.put(id, new ArrayList()); } _colocate.get(id).add(n); } }
private void addStateNode(AGENT agent, STATE state, ITimePeriod timePeriod, ITemporalSeries<STATE> temporalSeries, STATE parentState) { // add the state node to the agent's time series. will inherently check for illegal overlaps. temporalSeries.put(timePeriod, state); // register the state in the reverse index stateAgentReverseIndex.put(state, agent); stateTimePeriodIndex.put(state, timePeriod); // add the state node to the graph graph.addVertex(state); if (parentState != null) { // the parent has a CAUSAL relationship with the child graph.addEdge(parentState, state, new CausalRelationship()); } }
@NotNull @Override public <T> DirectedGraph<T, DefaultEdge> createSimpleDependencyGraph(@NotNull Iterable<? extends T> inputs, @NotNull Function1<? super T, ? extends Iterable<? extends T>> edgesFunction) { final DefaultDirectedGraph<T, DefaultEdge> graph = new DefaultDirectedGraph<T, DefaultEdge>(DefaultEdge.class); for (T input : inputs) { graph.addVertex(input); } for (T input : inputs) { Iterable<? extends T> targetVertices = edgesFunction.invoke(input); for (T targetVertex : targetVertices) { if (graph.containsVertex(targetVertex)) { graph.addEdge(targetVertex, input); } else { LOG.info("Problem?"); } } } return graph; }
@NotNull @Override public <T> DirectedGraph<T, DefaultEdge> createSimpleDependencyGraph(@NotNull Iterable<? extends T> inputs, @NotNull Function1<? super T, ? extends Iterable<? extends T>> edgesFunction) { final DefaultDirectedGraph<T, DefaultEdge> graph = new DefaultDirectedGraph<T, DefaultEdge>(DefaultEdge.class); for (T input : inputs) { graph.addVertex(input); } for (T input : inputs) { Iterable<? extends T> targetVertices = edgesFunction.invoke(input); for (T targetVertex : targetVertices) { if (graph.containsVertex(targetVertex)) { graph.addEdge(targetVertex, input); } else { LOG.info("Problem?"); } } } return graph; }
private List<Annotation> getOrderedAnnotations(Method method) { DefaultDirectedGraph<Annotation, DefaultEdge> graph = new DefaultDirectedGraph<Annotation, DefaultEdge>(DefaultEdge.class); for (Annotation annotation : method.getAnnotations()) { graph.addVertex(annotation); } for (Annotation annotation : method.getAnnotations()) { Class<? extends Annotation> thisClass = annotation.annotationType(); RunAfter runAfterAnnotation = thisClass.getAnnotation(RunAfter.class); if (runAfterAnnotation != null) { for (Class<? extends Annotation> otherClass : runAfterAnnotation.value()) { graph.addEdge(method.getAnnotation(otherClass), annotation); } } RunBefore runBeforeAnnotation = thisClass.getAnnotation(RunBefore.class); if (runBeforeAnnotation != null) { for (Class<? extends Annotation> otherClass : runBeforeAnnotation.value()) { graph.addEdge(annotation, method.getAnnotation(otherClass)); } } } return getOrderedReferences(graph); }
public void applyEnter(EventBean[] eventsPerStream, ExprEvaluatorContext exprEvaluatorContext) { Object from = factory.getFrom().evaluate(eventsPerStream, true, exprEvaluatorContext); Object to = factory.getTo().evaluate(eventsPerStream, true, exprEvaluatorContext); if (vertexReferenceCount.add(from)) { graph.addVertex(from); } if (vertexReferenceCount.add(to)) { graph.addVertex(to); } EventBean event = eventsPerStream[0]; graph.addEdge(from, to, event); }
static public <V> DefaultDirectedGraph<V, Edge<V>> getDefaultDiGraph(BinaryRelation<V, V> source) { final SimpleEdgeFactory<V> factory = new SimpleEdgeFactory<V>(); final DefaultDirectedGraph<V, Edge<V>> g = new DefaultDirectedGraph<V, Edge<V>>(factory); final Set<Pair<V, V>> pairs = source.asPairs(); for (Pair<V, V> pair : pairs) { g.addVertex(pair.getElt1()); g.addVertex(pair.getElt2()); g.addEdge(pair.getElt1(), pair.getElt2()); } return g; }
private void worker(DefaultDirectedGraph<TaskId, DefaultEdge> graph, Task task, TaskId parentId, ImmutableMap.Builder<TaskId, Task> tasksBuilder, Set<TaskId> usedTasksSet) { if ( usedTasksSet.add(task.getTaskId()) ) { tasksBuilder.put(task.getTaskId(), task); } graph.addVertex(task.getTaskId()); if ( parentId != null ) { graph.addEdge(parentId, task.getTaskId()); } task.getChildrenTasks().forEach(child -> worker(graph, child, task.getTaskId(), tasksBuilder, usedTasksSet)); } }
/** * Returns a reverted version of this graph in a jGraph * * That is a graph containing exactly the same nodes as this one but for * each edge from v1 to v2 in this graph the resulting graph will contain an * edge from v2 to v1 - or in other words the reverted edge * * This is used to revert CFGs in order to determine control dependencies * for example * * @return a {@link org.jgrapht.graph.DefaultDirectedGraph} object. */ protected DefaultDirectedGraph<V, E> computeReverseJGraph() { DefaultDirectedGraph<V, E> r = new DefaultDirectedGraph<V, E>(edgeClass); for (V v : vertexSet()) if (!r.addVertex(v)) throw new IllegalStateException( "internal error while adding vertices"); for (E e : edgeSet()) { V src = getEdgeSource(e); V target = getEdgeTarget(e); if (r.addEdge(target, src) == null) throw new IllegalStateException( "internal error while adding reverse edges"); } return r; }
private static DefaultDirectedGraph<DataRangeExpression,DefaultEdge> getDataRangeGraph (OntologyImpl.UnclassifiedOntologyTBox ontology, DefaultDirectedGraph<DataPropertyExpression,DefaultEdge> dataPropertyGraph) { DefaultDirectedGraph<DataRangeExpression,DefaultEdge> dataRangeGraph = new DefaultDirectedGraph<>(DefaultEdge.class); // ranges of roles for (DataPropertyExpression role : dataPropertyGraph.vertexSet()) dataRangeGraph.addVertex(role.getRange()); // edges between the ranges for sub-properties for (DefaultEdge edge : dataPropertyGraph.edgeSet()) { DataPropertyExpression child = dataPropertyGraph.getEdgeSource(edge); DataPropertyExpression parent = dataPropertyGraph.getEdgeTarget(edge); dataRangeGraph.addEdge(child.getRange(), parent.getRange()); } // data range inclusions from the ontology for (BinaryAxiom<DataRangeExpression> clsIncl : ontology.getSubDataRangeAxioms()) { dataRangeGraph.addVertex(clsIncl.getSuper()); // Datatype is not among the vertices from the start dataRangeGraph.addEdge(clsIncl.getSub(), clsIncl.getSuper()); } return dataRangeGraph; }
private static DefaultDirectedGraph<DataRangeExpression,DefaultEdge> getDataRangeGraph (OntologyImpl.UnclassifiedOntologyTBox ontology, DefaultDirectedGraph<DataPropertyExpression,DefaultEdge> dataPropertyGraph) { DefaultDirectedGraph<DataRangeExpression,DefaultEdge> dataRangeGraph = new DefaultDirectedGraph<>(DefaultEdge.class); // ranges of roles for (DataPropertyExpression role : dataPropertyGraph.vertexSet()) dataRangeGraph.addVertex(role.getRange()); // edges between the ranges for sub-properties for (DefaultEdge edge : dataPropertyGraph.edgeSet()) { DataPropertyExpression child = dataPropertyGraph.getEdgeSource(edge); DataPropertyExpression parent = dataPropertyGraph.getEdgeTarget(edge); dataRangeGraph.addEdge(child.getRange(), parent.getRange()); } // data range inclusions from the ontology for (BinaryAxiom<DataRangeExpression> clsIncl : ontology.getSubDataRangeAxioms()) { dataRangeGraph.addVertex(clsIncl.getSuper()); // Datatype is not among the vertices from the start dataRangeGraph.addEdge(clsIncl.getSub(), clsIncl.getSuper()); } return dataRangeGraph; }
@SuppressWarnings("unchecked") public BranchFitnessGraph(Set<FitnessFunction<T>> goals){ for (FitnessFunction<T> fitness : goals){ graph.addVertex(fitness);
public DefaultDirectedGraph<T,DefaultEdge> getGraph() { if (graph == null) { graph = new DefaultDirectedGraph<>(DefaultEdge.class); for (Equivalences<T> node : dag.vertexSet()) { for (T v : node) graph.addVertex(v); for (T v : node) { graph.addEdge(v, node.getRepresentative()); graph.addEdge(node.getRepresentative(), v); } } for (DefaultEdge edge : dag.edgeSet()) graph.addEdge(dag.getEdgeSource(edge).getRepresentative(), dag.getEdgeTarget(edge).getRepresentative()); } return graph; }
public DefaultDirectedGraph<T,DefaultEdge> getGraph() { if (graph == null) { graph = new DefaultDirectedGraph<>(DefaultEdge.class); for (Equivalences<T> node : dag.vertexSet()) { for (T v : node) graph.addVertex(v); for (T v : node) { graph.addEdge(v, node.getRepresentative()); graph.addEdge(node.getRepresentative(), v); } } for (DefaultEdge edge : dag.edgeSet()) graph.addEdge(dag.getEdgeSource(edge).getRepresentative(), dag.getEdgeTarget(edge).getRepresentative()); } return graph; }