private static int[][] successors(final List<Vector3D> vertices,final List<int[]> facets,final int[][] references){
  final int[][] successors=new int[vertices.size()][references[0].length];
  for (  final int[] s : successors) {
    Arrays.fill(s,-1);
  }
  for (int v=0; v < vertices.size(); ++v) {
    for (int k=0; k < successors[v].length && references[v][k] >= 0; ++k) {
      final int[] facet=facets.get(references[v][k]);
      int i=0;
      while (i < facet.length && facet[i] != v) {
        ++i;
      }
      successors[v][k]=facet[(i + 1) % facet.length];
      for (int l=0; l < k; ++l) {
        if (successors[v][l] == successors[v][k]) {
          final Vector3D start=vertices.get(v);
          final Vector3D end=vertices.get(successors[v][k]);
          throw new MathIllegalArgumentException(LocalizedGeometryFormats.FACET_ORIENTATION_MISMATCH,start.getX(),start.getY(),start.getZ(),end.getX(),end.getY(),end.getZ());
        }
      }
    }
  }
  return successors;
}

private static int [ ] [ ] successors ( final List < Vector3D > vertices , final List < int [ ] > facets , final int [ ] [ ] references ) { final int [ ] [ ] successors = new int [ vertices . size ( ) ] [ references [ 0 ] . length ] ; for ( final int [ ] s : successors ) { Arrays . fill ( s , - 1 ) ; } for ( int v = 0 ; v < vertices . size ( ) ; ++ v ) { for ( int k = 0 ; k < successors [ v ] . length && references [ v ] [ k ] >= 0 ; ++ k ) { final int [ ] facet = facets . get ( references [ v ] [ k ] ) ; int i = 0 ; while ( i < facet . length && facet [ i ] != v ) { ++ i ; } successors [ v ] [ k ] = facet [ ( i + 1 ) % facet . length ] ; for ( int l = 0 ; l < k ; ++ l ) { if ( successors [ v ] [ l ] == successors [ v ] [ k ] ) { final Vector3D start = vertices . get ( v ) ; final Vector3D end = vertices . get ( successors [ v ] [ k ] ) ; throw new MathIllegalArgumentException ( LocalizedGeometryFormats . FACET_ORIENTATION_MISMATCH , start . getX ( ) , start . getY ( ) , start . getZ ( ) , end . getX ( ) , end . getY ( ) , end . getZ ( ) ) ; } } } } return successors ; }
find the successors of all vertices among all facets they belong to .
