Repository: networkx/networkx

Issue:
calculating numeric assortativity requires int?
I am trying to use networkx to calculate numeric assortativity based on a numeric attribute that I set to nodes. My node attributes are floats. When I call the assortativity function:

`assort = nx.numeric_assortativity_coefficient(G,'float_attr')`

I got the following errors.

```
File "/some dir.../networkx/algorithms/assortativity/correlation.py", line 229, in numeric_assortativity_coefficient
a = numeric_mixing_matrix(G,attribute,nodes)
File "/some dir.../networkx/algorithms/assortativity/mixing.py", line 193, in numeric_mixing_matrix
mapping=dict(zip(range(m+1),range(m+1)))
TypeError: range() integer end argument expected, got float.
```

I checked the documentation page of networkx assortativity algorithm and it did not say the numeric attributes have to be int. Anyone knows if that's required?

BTW, I used the same network and a gender attribute (set to 0 and 1) to calculate both the attribute and the numeric assortativity. I had no problem with that. So it seems that the problem is with the int/float type of the node attribute. However, a lot of numeric node attributes are in fact continuous variables, which are best represented using float instead of int data type.

I would suggest either
1) make it clear in the documentation that the node attribute to calculate numeric assortativity requires int.
or
2) make changes to the code so that it can deal with float type of node attributes.



Discussion:
You are right - that function only works for discrete integer values.  It wouldn't be that hard I think to generalize that to the continuous case if someone would like to do that.  In the mean time the docs should be improved as you suggest.

On it. 


Resolving patch:
diff --git a/networkx/algorithms/assortativity/correlation.py b/networkx/algorithms/assortativity/correlation.py
--- a/networkx/algorithms/assortativity/correlation.py
+++ b/networkx/algorithms/assortativity/correlation.py
@@ -190,13 +190,15 @@ def numeric_assortativity_coefficient(G, attribute, nodes=None):
 
     Assortativity measures the similarity of connections
     in the graph with respect to the given numeric attribute.
-    
+    The numeric attribute must be an integer.
+
     Parameters
     ----------
     G : NetworkX graph
 
     attribute : string 
-        Node attribute key
+        Node attribute key.  The corresponding attribute value must be an
+        integer.
 
     nodes: list or iterable (optional)
         Compute numeric assortativity only for attributes of nodes in 
diff --git a/networkx/algorithms/assortativity/mixing.py b/networkx/algorithms/assortativity/mixing.py
--- a/networkx/algorithms/assortativity/mixing.py
+++ b/networkx/algorithms/assortativity/mixing.py
@@ -166,13 +166,15 @@ def degree_mixing_matrix(G, x='out', y='in', weight=None,
 def numeric_mixing_matrix(G,attribute,nodes=None,normalized=True):
     """Return numeric mixing matrix for attribute.
 
+    The attribute must be an integer.
+
     Parameters
     ----------
     G : graph 
        NetworkX graph object.
 
     attribute : string 
-       Node attribute key.
+       Node attribute key.  The corresponding attribute must be an integer.
 
     nodes: list or iterable (optional)
         Build the matrix only with nodes in container. The default is all nodes.


Test patch: