function generateMatrix(data){
    var indices = {},
        matrix = [],
        names = [],
        n = 0, i, j;

    function recordIndex(name){
      if( !(name in indices) ){
        indices[name] = n++;
        names.push(name);
      }
    }

    data.forEach(function (d){
      recordIndex(source(d));
      recordIndex(destination(d));
    });

    for(i = 0; i < n; i++){
      matrix.push([]);
      for(j = 0; j < n; j++){
        matrix[i].push(0);
      }
    }

    data.forEach(function (d){
      i = indices[source(d)];
      j = indices[destination(d)];

      if(chordWeightColumn){
        matrix[j][i] = weight(d);
      } else {

        // Handle the case where no weight column was specified
        // by making the chord weight fixed on both sides.
        matrix[j][i] = matrix[i][j] = 1;
      }
    });

    matrix.names = names;

    return matrix;
  }
// for use with the D3 Chord layout.
for use with the D3 Chord layout.
for use with the D3 Chord layout .
function generateMatrix(data){
    var indices = {},
        matrix = [],
        names = [],
        n = 0, i, j;
    function recordIndex(name){
      if( !(name in indices) ){
        indices[name] = n++;
        names.push(name);
      }
    }
    data.forEach(function (d){
      recordIndex(source(d));
      recordIndex(destination(d));
    });
    for(i = 0; i < n; i++){
      matrix.push([]);
      for(j = 0; j < n; j++){
        matrix[i].push(0);
      }
    }
    data.forEach(function (d){
      i = indices[source(d)];
      j = indices[destination(d)];
      if(chordWeightColumn){
        matrix[j][i] = weight(d);
      } else {
        matrix[j][i] = matrix[i][j] = 1;
      }
    });
    matrix.names = names;
    return matrix;
  }
function generateMatrix ( data ) { var indices = { } , matrix = [ ] , names = [ ] , n = 0 , i , j ; function recordIndex ( name ) { if ( ! ( name in indices ) ) { indices [ name ] = n ++ ; names . push ( name ) ; } } data . forEach ( function ( d ) { recordIndex ( source ( d ) ) ; recordIndex ( destination ( d ) ) ; } ) ; for ( i = 0 ; i < n ; i ++ ) { matrix . push ( [ ] ) ; for ( j = 0 ; j < n ; j ++ ) { matrix [ i ] . push ( 0 ) ; } } data . forEach ( function ( d ) { i = indices [ source ( d ) ] ; j = indices [ destination ( d ) ] ; if ( chordWeightColumn ) { matrix [ j ] [ i ] = weight ( d ) ; } else { matrix [ j ] [ i ] = matrix [ i ] [ j ] = 1 ; } } ) ; matrix . names = names ; return matrix ; }
for use with the D3 Chord layout.
for use with the D3 Chord layout .
// Handle the case where no weight column was specified // by making the chord weight fixed on both sides.