code: public RelationGraph annotationGraph(@NonNull Tuple relationTypes, @NonNull AnnotationType... annotationTypes) {
        RelationGraph g = new RelationGraph();
        List<Annotation> vertices = interleaved(annotationTypes);
        Set<RelationType> relationTypeList = Streams
                                                .asStream(relationTypes.iterator())
                                                .filter(r -> r instanceof RelationType)
                                                .map(Cast::<RelationType>as)
                                                .collect(Collectors.toSet());
        g.addVertices(vertices);
        for (Annotation source : vertices) {
           Collection<Relation> relations = source.relations(true);
           for (Relation relation : relations) {
              if (relationTypeList.contains(relation.getType())) {
                 relation
                    .getTarget(document())
                    .ifPresent(target -> {
                       target = g.containsVertex(target)
                                ? target
                                : target
                                     .stream(AnnotationType.ROOT)
                                     .filter(g::containsVertex)
                                     .findFirst()
                                     .orElse(null);
                       if (target != null) {
                          if (!g.containsEdge(source, target)) {
                             RelationEdge edge = g.addEdge(source, target);
                             edge.setRelation(relation.getValue());
                             edge.setRelationType(relation.getType());
                          }
                       }
                    });
              }
           }
        }
        return g;
     }
docs: <p>Constructs a relation graph with the given relation types as the edges and the given annotation types as the
  vertices (the {@link #interleaved(AnnotationType...)} method is used to get the annotations). Relations will be
  determine for annotations by including the relations of their sub-annotations (i.e. sub-spans). This allows, for
  example, a dependency graph to be built over other annotation types, e.g. phrase chunks.</p>
  
  @param relationTypes   the relation types making up the edges
  @param annotationTypes annotation types making up the vertices
  @return the relation graph