Repository: networkx/networkx

Issue:
is_graphical treats numpy int as not integers
There is a minor issue with using `is_graphical` function with numpy array.
When passing a numpy array with integers as the argument, `is_graphical` automatically returns `False` because numpy `int` type is not an instance of python `int` type.

Also there is no warning regarding the data type of input so I was very confused for a while when I had a clearly graphical degree sequence passed to the `is_graphical` and was returned `False`.

I would suggest considering numpy int as a valid integer type, otherwise I have to recreate a list of python integers from the array of numpy integers.

Also I think it is reasonable to raise an exception or print a warning when the data type of the input degree sequence is not a valid integer, because this case is fundamentally different from not being able to pass HH or EG tests. 

```
>>> import networkx as nx
>>> import numpy as np
>>> a = np.array([2,2,2])
>>> b = [2,2,2]
>>> nx.is_graphical(a)
False
>>> nx.is_graphical(b)
True
```


Discussion:
Thanks for this. 

Resolving patch:
diff --git a/networkx/algorithms/graphical.py b/networkx/algorithms/graphical.py
--- a/networkx/algorithms/graphical.py
+++ b/networkx/algorithms/graphical.py
@@ -35,7 +35,7 @@ def is_graphical(sequence, method='eg'):
     sequence : list or iterable container
         A sequence of integer node degrees
 
-    method : "eg" | "hh"
+    method : "eg" | "hh"  (default: 'eg')
         The method used to validate the degree sequence.
         "eg" corresponds to the Erdős-Gallai algorithm, and
         "hh" to the Havel-Hakimi algorithm.
@@ -73,7 +73,17 @@ def is_graphical(sequence, method='eg'):
 def _basic_graphical_tests(deg_sequence):
     # Sort and perform some simple tests on the sequence
     if not nx.utils.is_list_of_ints(deg_sequence):
-        raise nx.NetworkXUnfeasible
+        # check for a type that can be converted to int. Like numpy.int64
+        ds = []
+        for d in deg_sequence:
+            try:
+                intd = int(d)
+            except ValueError:
+                raise nx.NetworkXError("Invalid type in deg_sequence: not an integer")
+            if intd != d:
+                raise nx.NetworkXError("Invalid type in deg_sequence: not an integer")
+            ds.append(intd)
+        deg_sequence = ds
     p = len(deg_sequence)
     num_degs = [0] * p
     dmax, dmin, dsum, n = 0, p, 0, 0


Test patch:
diff --git a/networkx/algorithms/tests/test_graphical.py b/networkx/algorithms/tests/test_graphical.py
--- a/networkx/algorithms/tests/test_graphical.py
+++ b/networkx/algorithms/tests/test_graphical.py
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-from nose.tools import *
+from nose.tools import assert_true, assert_false, raises
 from nose import SkipTest
 import networkx as nx
 
@@ -31,7 +31,14 @@ def test_string_input():
 def test_negative_input():
     assert_false(nx.is_graphical([-1], 'hh'))
     assert_false(nx.is_graphical([-1], 'eg'))
-    assert_false(nx.is_graphical([72.5], 'eg'))
+
+@raises(nx.NetworkXException)
+def test_non_integer_input():
+    a = nx.is_graphical([72.5], 'eg')
+
+@raises(nx.NetworkXException)
+def test_non_integer_input():
+    a = nx.is_graphical([72.5], 'hh')
 
 
 class TestAtlas(object):
@@ -133,3 +140,24 @@ def test_pseudo_sequence():
     # Test for negative integer in sequence
     seq = [1000, 3, 3, 3, 3, 2, 2, -2, 1, 1]
     assert_false(nx.is_pseudographical(seq))
+
+def test_numpy_degree_sequence():
+    try:
+        import numpy
+    except ImportError:
+        return
+    ds = numpy.array([1, 2, 2, 2, 1], dtype=numpy.int64)
+    assert_true(nx.is_graphical(ds, 'eg'))
+    assert_true(nx.is_graphical(ds, 'hh'))
+    ds = numpy.array([1, 2, 2, 2, 1], dtype=numpy.float64)
+    assert_true(nx.is_graphical(ds, 'eg'))
+    assert_true(nx.is_graphical(ds, 'hh'))
+
+@raises(nx.NetworkXError, AssertionError)
+def test_numpy_noninteger_degree_sequence():
+    try:
+        import numpy
+    except ImportError:
+        raise nx.NetworkXError('make test pass by raising exception')
+    ds = numpy.array([1.1, 2, 2, 2, 1], dtype=numpy.float64)
+    a = nx.is_graphical(ds, 'eg')