code: public static GraphRole[] getRelatedElementsRoles(GraphEntity element,
              String relationshipname, String role) {
          Vector rels = element.getAllRelationships();
          Enumeration enumeration = rels.elements();
          Vector related = new Vector();
          while (enumeration.hasMoreElements()) {
              GraphRelationship gr = (GraphRelationship) enumeration
                      .nextElement();
              if (gr.getType().toLowerCase()
                      .equals(relationshipname.toLowerCase())) {
                  GraphRole[] roles = gr.getRoles();
                  for (int k = 0; k < roles.length; k++) {
                      if (roles[k].getName().toLowerCase()
                              .equals(role.toLowerCase())) {
                          related.add(roles[k]);
                      }
                  }
              }
          }
          return toGRoArray(related.toArray());
      }
docs: It obtains the extremes of the association of type "relationshipname",
  where one of their roles is "role", and originated in the "element"
  
  @param element The element to be studied
  @param relationshipname The name of the relationship which will be
  studied
  @param role The name of the extreme of the relationship that has to be
  studied
  @return An array of roles