The real wordsPractical
The geodesic distance matrix
Geodesic distanceThe length of the shortest path between two nodes, counted in edges. d(i,j).
Geodesic distance matrixThe square table of every d(i,j), with zeros down the diagonal.
Build it in waves from each node: the neighbours are at distance 1, their unvisited neighbours at 2, and so on. For an undirected network the matrix is symmetric, so you only have to fill half of it.
Every closeness and betweenness number comes out of this table, so build it first and check it before going on.