The clustering coefficient of a graph (or network) is a:
measure of degree to which nodes in a graph tend to cluster together
The Wikipedia article gives a much better description of how network average clustering coefficient is calculated from local clustering coefficients than I could give.
Given an adjacency matrix
a describing an undirected network (or graph) with no self loops, calculate it's network average clustering coefficient.
- You must write a program/function/procedure/code block which calculates the network average clustering coefficient for any undirected graph with no self loops.
- The output may only contain the coefficient and nothing else.
- You are to assume that your program (or whatever) has access to an adjacency matrix describing the graph through a variable/the stack/file/whatever
- You may not use any inbuilt functionality your language may have to calculate clustering coefficients
- Shortest code wins
Test inputs and outputs can be found in this pastebin
My solution: GNU Octave, 93 chars
Which can be tested here, the matrix needs to be in the format
a = [row ; row ; row ; ...]