def average_neighbor_distance(points, num_neigh):
if num_neigh > len(points) - <NUM_LIT:1>:<EOL><INDENT>raise NameError('<STR_LIT>');<EOL><DEDENT>dist_matrix = [ [ <NUM_LIT:0.0> for i in range(len(points)) ] for j in range(len(points)) ];<EOL>for i in range(<NUM_LIT:0>, len(points), <NUM_LIT:1>):<EOL><INDENT>for j in range(i + <NUM_LIT:1>, len(points), <NUM_LIT:1>):<EOL><INDENT>distance = euclidean_distance(points[i], points[j]);<EOL>dist_matrix[i][j] = distance;<EOL>dist_matrix[j][i] = distance;<EOL><DEDENT>dist_matrix[i] = sorted(dist_matrix[i]);<EOL><DEDENT>total_distance = <NUM_LIT:0>;<EOL>for i in range(<NUM_LIT:0>, len(points), <NUM_LIT:1>):<EOL><INDENT>for j in range(<NUM_LIT:0>, num_neigh, <NUM_LIT:1>):<EOL><INDENT>total_distance += dist_matrix[i][j + <NUM_LIT:1>];<EOL><DEDENT><DEDENT>return ( total_distance / (num_neigh * len(points)) )<EOL>
!
    @brief Returns average distance for establish links between specified number of nearest neighbors.

    @param[in] points (list): Input data, list of points where each point represented by list.
    @param[in] num_neigh (uint): Number of neighbors that should be used for distance calculation.

    @return (double) Average distance for establish links between 'num_neigh' in data set 'points'.