Repository: networkx/networkx

Issue:
(Di)Graph.add_nodes_from broken under IronPython
It seems that #1314 breaks (Di)Graph.add_nodes_from in IronPython on Travis pretty badly (see https://travis-ci.org/networkx/networkx/jobs/46474504#L3452 for example). I think that I fixed those functions before. IIRC, that was due to `<dict> in <dict>` returning `false` instead of raising `TypeError` in IronPython. #1314 apparently [reintroduced the same logic](https://github.com/networkx/networkx/pull/1314/files#diff-4fe234273eebd1a251430097d68e9854R403). I am not sure if that has been fixed in IronPython, or if .travis.yml is picking up the correct release.

Discussion:

Patch:
diff --git a/doc/source/developer/gitwash/forking_hell.rst b/doc/source/developer/gitwash/forking_hell.rst
index 1e29fc800..26b802ca0 100644
--- a/doc/source/developer/gitwash/forking_hell.rst
+++ b/doc/source/developer/gitwash/forking_hell.rst
@@ -5,7 +5,7 @@ Making your own copy (fork) of networkx
 ======================================================
 
 You need to do this only once.  The instructions here are very similar
-to the instructions at https://help.github.com/articles/fork-a-repo/ |emdash| please see
+to the instructions at http://help.github.com/forking/ |emdash| please see
 that page for more detail.  We're repeating some of it here just to give the
 specifics for the `networkx`_ project, and to suggest some default names.
 
diff --git a/doc/source/developer/gitwash/git_links.inc b/doc/source/developer/gitwash/git_links.inc
index 65ba945b1..8e628ae19 100644
--- a/doc/source/developer/gitwash/git_links.inc
+++ b/doc/source/developer/gitwash/git_links.inc
@@ -1,7 +1,7 @@
 .. This (-*- rst -*-) format file contains commonly used link targets
-   and name substitutions. It may be included in many files,
+   and name substitutions.  It may be included in many files,
    therefore it should only contain link targets and name
-   substitutions. Try grepping for "^\.\. _" to find plausible
+   substitutions.  Try grepping for "^\.\. _" to find plausible
    candidates for this list.
 
 .. NOTE: reST targets are
@@ -12,16 +12,20 @@
 .. _git: http://git-scm.com/
 .. _github: http://github.com
 .. _github help: http://help.github.com
-.. _github more help: https://help.github.com/articles/what-are-other-good-resources-for-learning-git-and-github/
 .. _msysgit: http://code.google.com/p/msysgit/downloads/list
 .. _git-osx-installer: http://code.google.com/p/git-osx-installer/downloads/list
 .. _subversion: http://subversion.tigris.org/
+.. _git cheat sheet: http://github.com/guides/git-cheat-sheet
+.. _pro git book: http://progit.org/
 .. _git svn crash course: http://git-scm.com/course/svn.html
+.. _learn.github: http://learn.github.com/
 .. _network graph visualizer: http://github.com/blog/39-say-hello-to-the-network-graph-visualizer
 .. _git user manual: http://schacon.github.com/git/user-manual.html
 .. _git tutorial: http://schacon.github.com/git/gittutorial.html
-.. _Nick Quaranto: http://www.gitready.com/
-.. _Fernando Perez: http://www.fperez.org/py4science/git.html
+.. _git community book: http://book.git-scm.com/
+.. _git ready: http://www.gitready.com/
+.. _git casts: http://www.gitcasts.com/
+.. _Fernando's git page: http://www.fperez.org/py4science/git.html
 .. _git magic: http://www-cs-students.stanford.edu/~blynn/gitmagic/index.html
 .. _git concepts: http://www.eecs.harvard.edu/~cduan/technical/git/
 .. _git clone: http://schacon.github.com/git/git-clone.html
@@ -40,7 +44,8 @@
 .. _why the -a flag?: http://www.gitready.com/beginner/2009/01/18/the-staging-area.html
 .. _git staging area: http://www.gitready.com/beginner/2009/01/18/the-staging-area.html
 .. _tangled working copy problem: http://tomayko.com/writings/the-thing-about-git 
-.. _Linus Torvalds: http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html
+.. _git management: http://kerneltrap.org/Linux/Git_Management
+.. _linux git workflow: http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html
 .. _git parable: http://tom.preston-werner.com/2009/05/19/the-git-parable.html
 .. _git foundation: http://matthew-brett.github.com/pydagogue/foundation.html
 .. _deleting master on github: http://matthew-brett.github.com/pydagogue/gh_delete_master.html
diff --git a/doc/source/developer/gitwash/git_resources.rst b/doc/source/developer/gitwash/git_resources.rst
index 4ab41c4e5..ba7b275e0 100644
--- a/doc/source/developer/gitwash/git_resources.rst
+++ b/doc/source/developer/gitwash/git_resources.rst
@@ -7,22 +7,34 @@ git resources
 Tutorials and summaries
 =======================
 
-`github help`_ is Git's own help and tutorial site. `github more help`_
- lists more resources for learning Git and GitHub, including YouTube
-channels. The list is constantly updated. In case you are used to subversion_
-, you can directly consult the `git svn crash course`_.
-
-To make full use of Git, you need to understand the concept behind Git.
-The following pages might help you:
-
-* `git parable`_ |emdash| an easy read parable
-* `git foundation`_ |emdash| more on the git parable
+* `github help`_ has an excellent series of how-to guides.
+* `learn.github`_ has an excellent series of tutorials
+* The `pro git book`_ is a good in-depth book on git. 
+* A `git cheat sheet`_ is a page giving summaries of common commands.
+* The `git user manual`_ 
+* The `git tutorial`_
+* The `git community book`_
+* `git ready`_ |emdash| a nice series of tutorials
+* `git casts`_ |emdash| video snippets giving git how-tos.
 * `git magic`_ |emdash| extended introduction with intermediate detail
-in many languages
-* `git concepts`_ |emdash| a technical page on the concepts
-
-Other than that, many devlopers list their personal tips and tricks.
-Among others there are `Fernando Perez`_, `Nick Quaranto`_ and `Linus Torvalds`_.
+* The `git parable`_ is an easy read explaining the concepts behind git.
+* `git foundation`_ expands on the `git parable`_.
+* Fernando Perez' git page |emdash| `Fernando's git page`_ |emdash| many
+  links and tips
+* A good but technical page on `git concepts`_
+* `git svn crash course`_: git for those of us used to subversion_
+
+Advanced git workflow
+=====================
+
+There are many ways of working with git; here are some posts on the
+rules of thumb that other projects have come up with:
+
+* Linus Torvalds on `git management`_
+* Linus Torvalds on `linux git workflow`_ .  Summary; use the git tools
+  to make the history of your edits as clean as possible; merge from
+  upstream edits as little as possible in branches where you are doing
+  active development.
 
 Manual pages online
 ===================
diff --git a/networkx/__init__.py b/networkx/__init__.py
index ef3f0baa4..1e03e8f58 100644
--- a/networkx/__init__.py
+++ b/networkx/__init__.py
@@ -50,18 +50,6 @@ __license__  = release.license
 __date__ = release.date
 __version__ = release.version
 
-__bibtex__ = """@inproceedings{hagberg-2008-exploring,
-author = {Aric A. Hagberg and Daniel A. Schult and Pieter J. Swart},
-title = {Exploring network structure, dynamics, and function using {NetworkX}},
-year = {2008},
-month = Aug,
-urlpdf = {http://math.lanl.gov/~hagberg/Papers/hagberg-2008-exploring.pdf},
-booktitle = {Proceedings of the 7th Python in Science Conference (SciPy2008)},
-editors = {G\"{a}el Varoquaux, Travis Vaught, and Jarrod Millman},
-address = {Pasadena, CA USA},
-pages = {11--15}
-}"""
-
 #These are import orderwise
 from networkx.exception import  *
 import networkx.external
diff --git a/networkx/classes/digraph.py b/networkx/classes/digraph.py
index 9f2a35921..9a5934675 100644
--- a/networkx/classes/digraph.py
+++ b/networkx/classes/digraph.py
@@ -399,8 +399,16 @@ class DiGraph(Graph):
 
         """
         for n in nodes:
+            # keep all this inside try/except because
+            # CPython throws TypeError on n not in self.succ,
+            # while pre-2.7.5 ironpython throws on self.succ[n] 
             try:
-                newnode=n not in self.succ
+                if n not in self.succ:
+                    self.succ[n] = self.adjlist_dict_factory()
+                    self.pred[n] = self.adjlist_dict_factory()
+                    self.node[n] = attr.copy()
+                else:
+                    self.node[n].update(attr)
             except TypeError:
                 nn,ndict = n
                 if nn not in self.succ:
@@ -413,13 +421,6 @@ class DiGraph(Graph):
                     olddict = self.node[nn]
                     olddict.update(attr)
                     olddict.update(ndict)
-                continue
-            if newnode:
-                self.succ[n] = self.adjlist_dict_factory()
-                self.pred[n] = self.adjlist_dict_factory()
-                self.node[n] = attr.copy()
-            else:
-                self.node[n].update(attr)
 
     def remove_node(self, n):
         """Remove node n.
diff --git a/networkx/classes/graph.py b/networkx/classes/graph.py
index 8d6a1afbf..24203f0d0 100644
--- a/networkx/classes/graph.py
+++ b/networkx/classes/graph.py
@@ -507,8 +507,15 @@ class Graph(object):
 
         """
         for n in nodes:
+            # keep all this inside try/except because
+            # CPython throws TypeError on n not in self.succ,
+            # while pre-2.7.5 ironpython throws on self.succ[n] 
             try:
-                newnode=n not in self.node
+                if n not in self.node:
+                    self.adj[n] = self.adjlist_dict_factory()
+                    self.node[n] = attr.copy()
+                else:
+                    self.node[n].update(attr)
             except TypeError:
                 nn,ndict = n
                 if nn not in self.node:
@@ -520,12 +527,6 @@ class Graph(object):
                     olddict = self.node[nn]
                     olddict.update(attr)
                     olddict.update(ndict)
-                continue
-            if newnode:
-                self.adj[n] = self.adjlist_dict_factory()
-                self.node[n] = attr.copy()
-            else:
-                self.node[n].update(attr)
 
     def remove_node(self,n):
         """Remove node n.
diff --git a/networkx/drawing/nx_pylab.py b/networkx/drawing/nx_pylab.py
index d92a90e83..27eba1e4b 100644
--- a/networkx/drawing/nx_pylab.py
+++ b/networkx/drawing/nx_pylab.py
@@ -182,7 +182,7 @@ def draw_networkx(G, pos=None, with_labels=True, **kwds):
        marker, one of 'so^>v<dph8'.
 
     alpha : float, optional (default=1.0)
-       The node and edge transparency
+       The node transparency
 
     cmap : Matplotlib colormap, optional (default=None)
        Colormap for mapping intensities of nodes
@@ -395,7 +395,7 @@ def draw_networkx_edges(G, pos,
                         width=1.0,
                         edge_color='k',
                         style='solid',
-                        alpha=1.0,
+                        alpha=None,
                         edge_cmap=None,
                         edge_vmin=None,
                         edge_vmax=None,
diff --git a/networkx/readwrite/json_graph/node_link.py b/networkx/readwrite/json_graph/node_link.py
index 4a89fb5a9..530560880 100644
--- a/networkx/readwrite/json_graph/node_link.py
+++ b/networkx/readwrite/json_graph/node_link.py
@@ -56,9 +56,8 @@ def node_link_data(G, attrs=_attrs):
 
     Notes
     -----
-    Graph, node, and link attributes are stored in this format. Note that
-    attribute keys will be converted to strings in order to comply with
-    JSON.
+    Graph, node, and link attributes are stored in this format but keys
+    for attributes must be strings if you want to serialize with JSON.
 
     The default value of attrs will be changed in a future release of NetworkX.
 
@@ -78,7 +77,7 @@ def node_link_data(G, attrs=_attrs):
     data = {}
     data['directed'] = G.is_directed()
     data['multigraph'] = multigraph
-    data['graph'] = G.graph
+    data['graph'] = list(G.graph.items())
     data['nodes'] = [dict(chain(G.node[n].items(), [(id_, n)])) for n in G]
     if multigraph:
         data['links'] = [
@@ -130,7 +129,6 @@ def node_link_graph(data, directed=False, multigraph=True, attrs=_attrs):
     -----
     The default value of attrs will be changed in a future release of NetworkX.
 
-
     See Also
     --------
     node_link_data, adjacency_data, tree_data
@@ -149,7 +147,7 @@ def node_link_graph(data, directed=False, multigraph=True, attrs=_attrs):
     # Allow 'key' to be omitted from attrs if the graph is not a multigraph.
     key = None if not multigraph else attrs['key']
     mapping = []
-    graph.graph = data.get('graph', {})
+    graph.graph = dict(data.get('graph', []))
     c = count()
     for d in data['nodes']:
         node = d.get(id_, next(c))


Test patch:
diff --git a/doc/source/developer/gitwash/following_latest.rst b/doc/source/developer/gitwash/following_latest.rst
index 9498bc359..bfca30786 100644
--- a/doc/source/developer/gitwash/following_latest.rst
+++ b/doc/source/developer/gitwash/following_latest.rst
@@ -25,33 +25,12 @@ You now have a copy of the code tree in the new ``networkx`` directory.
 Updating the code
 =================
 
-From time to time you may want to pull down the latest code. It is necessary
-to add the networkx repository as a remote to your configuration file. We call it
-upstream.
-
-   git remote set-url upstream https://github.com/networkx/networkx.git
-
-Now git knows where to fetch updates from.
+From time to time you may want to pull down the latest code.  Do this with::
 
    cd networkx
-   git fetch upstream
+   git pull
 
 The tree in ``networkx`` will now have the latest changes from the initial
-repository, unless you have made local changes in the meantime. In this case, you have to merge.
-
-    git merge upstream/master
-
-It is also possible to update your local fork directly from GitHub:
-
-1. Open your fork on GitHub.
-2. Click on 'Pull Requests'.
-3. Click on 'New Pull Request'. By default, GitHub will compare the original with your fork. If
-you didn’t make any changes, there is nothing to compare.
-4. Click on 'Switching the base' or click 'Edit' and switch the base manually. Now GitHub will
-compare your fork with the original, and you should see all the latest changes.
-5. Click on 'Click to create a pull request for this comparison' and name your pull request.
-6. Click on Send pull request.
-7. Scroll down and click 'Merge pull request' and finally 'Confirm merge'. You will be able to merge 
-it automatically unless you didnot change you local repo.
+repository.
 
 .. include:: links.inc
diff --git a/networkx/readwrite/json_graph/tests/test_node_link.py b/networkx/readwrite/json_graph/tests/test_node_link.py
index a9582b765..85c8fd1cb 100644
--- a/networkx/readwrite/json_graph/tests/test_node_link.py
+++ b/networkx/readwrite/json_graph/tests/test_node_link.py
@@ -23,10 +23,10 @@ class TestNodeLink:
         assert_equal(H.node[1]['color'],'red')
         assert_equal(H[1][2]['width'],7)
 
-        d = json.dumps(node_link_data(G))
+        d=json.dumps(node_link_data(G))
         H = node_link_graph(json.loads(d))
         assert_equal(H.graph['foo'],'bar')
-        assert_equal(H.graph['1'],'one')
+        assert_equal(H.graph[1],'one')
         assert_equal(H.node[1]['color'],'red')
         assert_equal(H[1][2]['width'],7)