Java Code Examples for org.jgrapht.graph.DefaultDirectedGraph#addVertex()

The following examples show how to use org.jgrapht.graph.DefaultDirectedGraph#addVertex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractRMLProcessor.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
private static boolean addCondition(TriplesMap from, TriplesMap target,
		DefaultDirectedGraph<TriplesMap, DefaultEdge> xx) {

	if (xx.containsEdge(from, target)) {
		return false;
	}
	xx.addVertex(from);
	xx.addVertex(target);

	Set<DefaultEdge> incoming = xx.incomingEdgesOf(target);
	DefaultEdge incedge = null;
	for (DefaultEdge e : incoming) {
		incedge = e;
		break;
	}
	if (incedge == null) {
		xx.addEdge(from, target);
	} else {
		manage(incedge, from, xx);
	}
	return true;
}
 
Example 2
Source File: RunnableTaskDagBuilder.java    From workflow with Apache License 2.0 5 votes vote down vote up
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));
}