We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Added implementation of SimRank matrix of the graph.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `networkx/relabel.py`
Content:
```
1 #    Copyright (C) 2006-2013 by
2 #    Aric Hagberg <hagberg@lanl.gov>
3 #    Dan Schult <dschult@colgate.edu>
4 #    Pieter Swart <swart@lanl.gov>
5 #    All rights reserved.
6 #    BSD license.
7 import networkx as nx
8 __author__ = """\n""".join(['Aric Hagberg <aric.hagberg@gmail.com>',
9                            'Pieter Swart (swart@lanl.gov)',
10                            'Dan Schult (dschult@colgate.edu)'])
11 __all__ = ['convert_node_labels_to_integers', 'relabel_nodes']
12 
13 def relabel_nodes(G, mapping, copy=True):
14     """Relabel the nodes of the graph G.
15 
16     Parameters
17     ----------
18     G : graph
19        A NetworkX graph
20 
21     mapping : dictionary
22        A dictionary with the old labels as keys and new labels as values.
23        A partial mapping is allowed.
24 
25     copy : bool (optional, default=True)
26        If True return a copy, or if False relabel the nodes in place.
27 
28     Examples
29     --------
30     >>> G=nx.path_graph(3)  # nodes 0-1-2
31     >>> mapping={0:'a',1:'b',2:'c'}
32     >>> H=nx.relabel_nodes(G,mapping)
33     >>> print(sorted(H.nodes()))
34     ['a', 'b', 'c']
35 
36     >>> G=nx.path_graph(26) # nodes 0..25
37     >>> mapping=dict(zip(G.nodes(),"abcdefghijklmnopqrstuvwxyz"))
38     >>> H=nx.relabel_nodes(G,mapping) # nodes a..z
39     >>> mapping=dict(zip(G.nodes(),range(1,27)))
40     >>> G1=nx.relabel_nodes(G,mapping) # nodes 1..26
41 
42     Partial in-place mapping:
43 
44     >>> G=nx.path_graph(3)  # nodes 0-1-2
45     >>> mapping={0:'a',1:'b'} # 0->'a' and 1->'b'
46     >>> G=nx.relabel_nodes(G,mapping, copy=False)
47 
48     print(G.nodes())
49     [2, 'b', 'a']
50 
51     Mapping as function:
52 
53     >>> G=nx.path_graph(3)
54     >>> def mapping(x):
55     ...    return x**2
56     >>> H=nx.relabel_nodes(G,mapping)
57     >>> print(H.nodes())
58     [0, 1, 4]
59 
60     Notes
61     -----
62     Only the nodes specified in the mapping will be relabeled.
63 
64     The keyword setting copy=False modifies the graph in place.
65     This is not always possible if the mapping is circular.
66     In that case use copy=True.
67 
68     See Also
69     --------
70     convert_node_labels_to_integers
71     """
72     # you can pass a function f(old_label)->new_label
73     # but we'll just make a dictionary here regardless
74     if not hasattr(mapping,"__getitem__"):
75         m = dict((n, mapping(n)) for n in G)
76     else:
77         m = mapping
78     if copy:
79         return _relabel_copy(G, m)
80     else:
81         return _relabel_inplace(G, m)
82 
83 
84 def _relabel_inplace(G, mapping):
85     old_labels = set(mapping.keys())
86     new_labels = set(mapping.values())
87     if len(old_labels & new_labels) > 0:
88         # labels sets overlap
89         # can we topological sort and still do the relabeling?
90         D = nx.DiGraph(list(mapping.items()))
91         D.remove_edges_from(D.selfloop_edges())
92         try:
93             nodes = nx.topological_sort(D, reverse=True)
94         except nx.NetworkXUnfeasible:
95             raise nx.NetworkXUnfeasible('The node label sets are overlapping '
96                                         'and no ordering can resolve the '
97                                         'mapping. Use copy=True.')
98     else:
99         # non-overlapping label sets
100         nodes = old_labels
101 
102     multigraph = G.is_multigraph()
103     directed = G.is_directed()
104 
105     for old in nodes:
106         try:
107             new = mapping[old]
108         except KeyError:
109             continue
110         try:
111             G.add_node(new, attr_dict=G.node[old])
112         except KeyError:
113             raise KeyError("Node %s is not in the graph"%old)
114         if multigraph:
115             new_edges = [(new, new if old == target else target, key, data)
116                          for (_,target,key,data)
117                          in G.edges(old, data=True, keys=True)]
118             if directed:
119                 new_edges += [(new if old == source else source, new, key, data)
120                               for (source, _, key,data)
121                               in G.in_edges(old, data=True, keys=True)]
122         else:
123             new_edges = [(new, new if old == target else target, data)
124                          for (_,target,data) in G.edges(old, data=True)]
125             if directed:
126                 new_edges += [(new if old == source else source,new,data)
127                               for (source,_,data) in G.in_edges(old, data=True)]
128         G.remove_node(old)
129         G.add_edges_from(new_edges)
130     return G
131 
132 def _relabel_copy(G, mapping):
133     H = G.__class__()
134     H.name = "(%s)" % G.name
135     if G.is_multigraph():
136         H.add_edges_from( (mapping.get(n1, n1),mapping.get(n2, n2),k,d.copy())
137                           for (n1,n2,k,d) in G.edges_iter(keys=True, data=True))
138     else:
139         H.add_edges_from( (mapping.get(n1, n1),mapping.get(n2, n2),d.copy())
140                           for (n1, n2, d) in G.edges_iter(data=True))
141 
142     H.add_nodes_from(mapping.get(n, n) for n in G)
143     H.node.update(dict((mapping.get(n, n), d.copy()) for n,d in G.node.items()))
144     H.graph.update(G.graph.copy())
145 
146     return H
147 
148 
149 def convert_node_labels_to_integers(G, first_label=0, ordering="default",
150                                     label_attribute=None):
151     """Return a copy of the graph G with the nodes relabeled using
152     consecutive integers.
153 
154     Parameters
155     ----------
156     G : graph
157        A NetworkX graph
158 
159     first_label : int, optional (default=0)
160        An integer specifying the starting offset in numbering nodes.
161        The new integer labels are numbered first_label, ..., n-1+first_label.
162 
163     ordering : string
164        "default" : inherit node ordering from G.nodes()
165        "sorted"  : inherit node ordering from sorted(G.nodes())
166        "increasing degree" : nodes are sorted by increasing degree
167        "decreasing degree" : nodes are sorted by decreasing degree
168 
169     label_attribute : string, optional (default=None)
170        Name of node attribute to store old label.  If None no attribute
171        is created.
172 
173     Notes
174     -----
175     Node and edge attribute data are copied to the new (relabeled) graph.
176 
177     See Also
178     --------
179     relabel_nodes
180     """
181     N = G.number_of_nodes()+first_label
182     if ordering == "default":
183         mapping = dict(zip(G.nodes(), range(first_label, N)))
184     elif ordering == "sorted":
185         nlist = G.nodes()
186         nlist.sort()
187         mapping = dict(zip(nlist, range(first_label, N)))
188     elif ordering == "increasing degree":
189         dv_pairs = [(d,n) for (n,d) in G.degree_iter()]
190         dv_pairs.sort() # in-place sort from lowest to highest degree
191         mapping = dict(zip([n for d,n in dv_pairs], range(first_label, N)))
192     elif ordering == "decreasing degree":
193         dv_pairs = [(d,n) for (n,d) in G.degree_iter()]
194         dv_pairs.sort() # in-place sort from lowest to highest degree
195         dv_pairs.reverse()
196         mapping = dict(zip([n for d,n in dv_pairs], range(first_label, N)))
197     else:
198         raise nx.NetworkXError('Unknown node ordering: %s'%ordering)
199     H = relabel_nodes(G, mapping)
200     H.name = "("+G.name+")_with_int_labels"
201     # create node attribute with the old label
202     if label_attribute is not None:
203         nx.set_node_attributes(H, label_attribute,
204                                dict((v,k) for k,v in mapping.items()))
205     return H
206
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/networkx/relabel.py b/networkx/relabel.py
--- a/networkx/relabel.py
+++ b/networkx/relabel.py
@@ -107,6 +107,8 @@
             new = mapping[old]
         except KeyError:
             continue
+        if new == old:
+            continue
         try:
             G.add_node(new, attr_dict=G.node[old])
         except KeyError:

{"golden_diff": "diff --git a/networkx/relabel.py b/networkx/relabel.py\n--- a/networkx/relabel.py\n+++ b/networkx/relabel.py\n@@ -107,6 +107,8 @@\n             new = mapping[old]\n         except KeyError:\n             continue\n+        if new == old:\n+            continue\n         try:\n             G.add_node(new, attr_dict=G.node[old])\n         except KeyError:\n", "issue": "Added implementation of SimRank matrix of the graph.\n\n", "before_files": [{"content": "#    Copyright (C) 2006-2013 by\n#    Aric Hagberg <hagberg@lanl.gov>\n#    Dan Schult <dschult@colgate.edu>\n#    Pieter Swart <swart@lanl.gov>\n#    All rights reserved.\n#    BSD license.\nimport networkx as nx\n__author__ = \"\"\"\\n\"\"\".join(['Aric Hagberg <aric.hagberg@gmail.com>',\n                           'Pieter Swart (swart@lanl.gov)',\n                           'Dan Schult (dschult@colgate.edu)'])\n__all__ = ['convert_node_labels_to_integers', 'relabel_nodes']\n\ndef relabel_nodes(G, mapping, copy=True):\n    \"\"\"Relabel the nodes of the graph G.\n\n    Parameters\n    ----------\n    G : graph\n       A NetworkX graph\n\n    mapping : dictionary\n       A dictionary with the old labels as keys and new labels as values.\n       A partial mapping is allowed.\n\n    copy : bool (optional, default=True)\n       If True return a copy, or if False relabel the nodes in place.\n\n    Examples\n    --------\n    >>> G=nx.path_graph(3)  # nodes 0-1-2\n    >>> mapping={0:'a',1:'b',2:'c'}\n    >>> H=nx.relabel_nodes(G,mapping)\n    >>> print(sorted(H.nodes()))\n    ['a', 'b', 'c']\n\n    >>> G=nx.path_graph(26) # nodes 0..25\n    >>> mapping=dict(zip(G.nodes(),\"abcdefghijklmnopqrstuvwxyz\"))\n    >>> H=nx.relabel_nodes(G,mapping) # nodes a..z\n    >>> mapping=dict(zip(G.nodes(),range(1,27)))\n    >>> G1=nx.relabel_nodes(G,mapping) # nodes 1..26\n\n    Partial in-place mapping:\n\n    >>> G=nx.path_graph(3)  # nodes 0-1-2\n    >>> mapping={0:'a',1:'b'} # 0->'a' and 1->'b'\n    >>> G=nx.relabel_nodes(G,mapping, copy=False)\n\n    print(G.nodes())\n    [2, 'b', 'a']\n\n    Mapping as function:\n\n    >>> G=nx.path_graph(3)\n    >>> def mapping(x):\n    ...    return x**2\n    >>> H=nx.relabel_nodes(G,mapping)\n    >>> print(H.nodes())\n    [0, 1, 4]\n\n    Notes\n    -----\n    Only the nodes specified in the mapping will be relabeled.\n\n    The keyword setting copy=False modifies the graph in place.\n    This is not always possible if the mapping is circular.\n    In that case use copy=True.\n\n    See Also\n    --------\n    convert_node_labels_to_integers\n    \"\"\"\n    # you can pass a function f(old_label)->new_label\n    # but we'll just make a dictionary here regardless\n    if not hasattr(mapping,\"__getitem__\"):\n        m = dict((n, mapping(n)) for n in G)\n    else:\n        m = mapping\n    if copy:\n        return _relabel_copy(G, m)\n    else:\n        return _relabel_inplace(G, m)\n\n\ndef _relabel_inplace(G, mapping):\n    old_labels = set(mapping.keys())\n    new_labels = set(mapping.values())\n    if len(old_labels & new_labels) > 0:\n        # labels sets overlap\n        # can we topological sort and still do the relabeling?\n        D = nx.DiGraph(list(mapping.items()))\n        D.remove_edges_from(D.selfloop_edges())\n        try:\n            nodes = nx.topological_sort(D, reverse=True)\n        except nx.NetworkXUnfeasible:\n            raise nx.NetworkXUnfeasible('The node label sets are overlapping '\n                                        'and no ordering can resolve the '\n                                        'mapping. Use copy=True.')\n    else:\n        # non-overlapping label sets\n        nodes = old_labels\n\n    multigraph = G.is_multigraph()\n    directed = G.is_directed()\n\n    for old in nodes:\n        try:\n            new = mapping[old]\n        except KeyError:\n            continue\n        try:\n            G.add_node(new, attr_dict=G.node[old])\n        except KeyError:\n            raise KeyError(\"Node %s is not in the graph\"%old)\n        if multigraph:\n            new_edges = [(new, new if old == target else target, key, data)\n                         for (_,target,key,data)\n                         in G.edges(old, data=True, keys=True)]\n            if directed:\n                new_edges += [(new if old == source else source, new, key, data)\n                              for (source, _, key,data)\n                              in G.in_edges(old, data=True, keys=True)]\n        else:\n            new_edges = [(new, new if old == target else target, data)\n                         for (_,target,data) in G.edges(old, data=True)]\n            if directed:\n                new_edges += [(new if old == source else source,new,data)\n                              for (source,_,data) in G.in_edges(old, data=True)]\n        G.remove_node(old)\n        G.add_edges_from(new_edges)\n    return G\n\ndef _relabel_copy(G, mapping):\n    H = G.__class__()\n    H.name = \"(%s)\" % G.name\n    if G.is_multigraph():\n        H.add_edges_from( (mapping.get(n1, n1),mapping.get(n2, n2),k,d.copy())\n                          for (n1,n2,k,d) in G.edges_iter(keys=True, data=True))\n    else:\n        H.add_edges_from( (mapping.get(n1, n1),mapping.get(n2, n2),d.copy())\n                          for (n1, n2, d) in G.edges_iter(data=True))\n\n    H.add_nodes_from(mapping.get(n, n) for n in G)\n    H.node.update(dict((mapping.get(n, n), d.copy()) for n,d in G.node.items()))\n    H.graph.update(G.graph.copy())\n\n    return H\n\n\ndef convert_node_labels_to_integers(G, first_label=0, ordering=\"default\",\n                                    label_attribute=None):\n    \"\"\"Return a copy of the graph G with the nodes relabeled using\n    consecutive integers.\n\n    Parameters\n    ----------\n    G : graph\n       A NetworkX graph\n\n    first_label : int, optional (default=0)\n       An integer specifying the starting offset in numbering nodes.\n       The new integer labels are numbered first_label, ..., n-1+first_label.\n\n    ordering : string\n       \"default\" : inherit node ordering from G.nodes()\n       \"sorted\"  : inherit node ordering from sorted(G.nodes())\n       \"increasing degree\" : nodes are sorted by increasing degree\n       \"decreasing degree\" : nodes are sorted by decreasing degree\n\n    label_attribute : string, optional (default=None)\n       Name of node attribute to store old label.  If None no attribute\n       is created.\n\n    Notes\n    -----\n    Node and edge attribute data are copied to the new (relabeled) graph.\n\n    See Also\n    --------\n    relabel_nodes\n    \"\"\"\n    N = G.number_of_nodes()+first_label\n    if ordering == \"default\":\n        mapping = dict(zip(G.nodes(), range(first_label, N)))\n    elif ordering == \"sorted\":\n        nlist = G.nodes()\n        nlist.sort()\n        mapping = dict(zip(nlist, range(first_label, N)))\n    elif ordering == \"increasing degree\":\n        dv_pairs = [(d,n) for (n,d) in G.degree_iter()]\n        dv_pairs.sort() # in-place sort from lowest to highest degree\n        mapping = dict(zip([n for d,n in dv_pairs], range(first_label, N)))\n    elif ordering == \"decreasing degree\":\n        dv_pairs = [(d,n) for (n,d) in G.degree_iter()]\n        dv_pairs.sort() # in-place sort from lowest to highest degree\n        dv_pairs.reverse()\n        mapping = dict(zip([n for d,n in dv_pairs], range(first_label, N)))\n    else:\n        raise nx.NetworkXError('Unknown node ordering: %s'%ordering)\n    H = relabel_nodes(G, mapping)\n    H.name = \"(\"+G.name+\")_with_int_labels\"\n    # create node attribute with the old label\n    if label_attribute is not None:\n        nx.set_node_attributes(H, label_attribute,\n                               dict((v,k) for k,v in mapping.items()))\n    return H\n", "path": "networkx/relabel.py"}], "after_files": [{"content": "#    Copyright (C) 2006-2013 by\n#    Aric Hagberg <hagberg@lanl.gov>\n#    Dan Schult <dschult@colgate.edu>\n#    Pieter Swart <swart@lanl.gov>\n#    All rights reserved.\n#    BSD license.\nimport networkx as nx\n__author__ = \"\"\"\\n\"\"\".join(['Aric Hagberg <aric.hagberg@gmail.com>',\n                           'Pieter Swart (swart@lanl.gov)',\n                           'Dan Schult (dschult@colgate.edu)'])\n__all__ = ['convert_node_labels_to_integers', 'relabel_nodes']\n\ndef relabel_nodes(G, mapping, copy=True):\n    \"\"\"Relabel the nodes of the graph G.\n\n    Parameters\n    ----------\n    G : graph\n       A NetworkX graph\n\n    mapping : dictionary\n       A dictionary with the old labels as keys and new labels as values.\n       A partial mapping is allowed.\n\n    copy : bool (optional, default=True)\n       If True return a copy, or if False relabel the nodes in place.\n\n    Examples\n    --------\n    >>> G=nx.path_graph(3)  # nodes 0-1-2\n    >>> mapping={0:'a',1:'b',2:'c'}\n    >>> H=nx.relabel_nodes(G,mapping)\n    >>> print(sorted(H.nodes()))\n    ['a', 'b', 'c']\n\n    >>> G=nx.path_graph(26) # nodes 0..25\n    >>> mapping=dict(zip(G.nodes(),\"abcdefghijklmnopqrstuvwxyz\"))\n    >>> H=nx.relabel_nodes(G,mapping) # nodes a..z\n    >>> mapping=dict(zip(G.nodes(),range(1,27)))\n    >>> G1=nx.relabel_nodes(G,mapping) # nodes 1..26\n\n    Partial in-place mapping:\n\n    >>> G=nx.path_graph(3)  # nodes 0-1-2\n    >>> mapping={0:'a',1:'b'} # 0->'a' and 1->'b'\n    >>> G=nx.relabel_nodes(G,mapping, copy=False)\n\n    print(G.nodes())\n    [2, 'b', 'a']\n\n    Mapping as function:\n\n    >>> G=nx.path_graph(3)\n    >>> def mapping(x):\n    ...    return x**2\n    >>> H=nx.relabel_nodes(G,mapping)\n    >>> print(H.nodes())\n    [0, 1, 4]\n\n    Notes\n    -----\n    Only the nodes specified in the mapping will be relabeled.\n\n    The keyword setting copy=False modifies the graph in place.\n    This is not always possible if the mapping is circular.\n    In that case use copy=True.\n\n    See Also\n    --------\n    convert_node_labels_to_integers\n    \"\"\"\n    # you can pass a function f(old_label)->new_label\n    # but we'll just make a dictionary here regardless\n    if not hasattr(mapping,\"__getitem__\"):\n        m = dict((n, mapping(n)) for n in G)\n    else:\n        m = mapping\n    if copy:\n        return _relabel_copy(G, m)\n    else:\n        return _relabel_inplace(G, m)\n\n\ndef _relabel_inplace(G, mapping):\n    old_labels = set(mapping.keys())\n    new_labels = set(mapping.values())\n    if len(old_labels & new_labels) > 0:\n        # labels sets overlap\n        # can we topological sort and still do the relabeling?\n        D = nx.DiGraph(list(mapping.items()))\n        D.remove_edges_from(D.selfloop_edges())\n        try:\n            nodes = nx.topological_sort(D, reverse=True)\n        except nx.NetworkXUnfeasible:\n            raise nx.NetworkXUnfeasible('The node label sets are overlapping '\n                                        'and no ordering can resolve the '\n                                        'mapping. Use copy=True.')\n    else:\n        # non-overlapping label sets\n        nodes = old_labels\n\n    multigraph = G.is_multigraph()\n    directed = G.is_directed()\n\n    for old in nodes:\n        try:\n            new = mapping[old]\n        except KeyError:\n            continue\n        if new == old:\n            continue\n        try:\n            G.add_node(new, attr_dict=G.node[old])\n        except KeyError:\n            raise KeyError(\"Node %s is not in the graph\"%old)\n        if multigraph:\n            new_edges = [(new, new if old == target else target, key, data)\n                         for (_,target,key,data)\n                         in G.edges(old, data=True, keys=True)]\n            if directed:\n                new_edges += [(new if old == source else source, new, key, data)\n                              for (source, _, key,data)\n                              in G.in_edges(old, data=True, keys=True)]\n        else:\n            new_edges = [(new, new if old == target else target, data)\n                         for (_,target,data) in G.edges(old, data=True)]\n            if directed:\n                new_edges += [(new if old == source else source,new,data)\n                              for (source,_,data) in G.in_edges(old, data=True)]\n        G.remove_node(old)\n        G.add_edges_from(new_edges)\n    return G\n\ndef _relabel_copy(G, mapping):\n    H = G.__class__()\n    H.name = \"(%s)\" % G.name\n    if G.is_multigraph():\n        H.add_edges_from( (mapping.get(n1, n1),mapping.get(n2, n2),k,d.copy())\n                          for (n1,n2,k,d) in G.edges_iter(keys=True, data=True))\n    else:\n        H.add_edges_from( (mapping.get(n1, n1),mapping.get(n2, n2),d.copy())\n                          for (n1, n2, d) in G.edges_iter(data=True))\n\n    H.add_nodes_from(mapping.get(n, n) for n in G)\n    H.node.update(dict((mapping.get(n, n), d.copy()) for n,d in G.node.items()))\n    H.graph.update(G.graph.copy())\n\n    return H\n\n\ndef convert_node_labels_to_integers(G, first_label=0, ordering=\"default\",\n                                    label_attribute=None):\n    \"\"\"Return a copy of the graph G with the nodes relabeled using\n    consecutive integers.\n\n    Parameters\n    ----------\n    G : graph\n       A NetworkX graph\n\n    first_label : int, optional (default=0)\n       An integer specifying the starting offset in numbering nodes.\n       The new integer labels are numbered first_label, ..., n-1+first_label.\n\n    ordering : string\n       \"default\" : inherit node ordering from G.nodes()\n       \"sorted\"  : inherit node ordering from sorted(G.nodes())\n       \"increasing degree\" : nodes are sorted by increasing degree\n       \"decreasing degree\" : nodes are sorted by decreasing degree\n\n    label_attribute : string, optional (default=None)\n       Name of node attribute to store old label.  If None no attribute\n       is created.\n\n    Notes\n    -----\n    Node and edge attribute data are copied to the new (relabeled) graph.\n\n    See Also\n    --------\n    relabel_nodes\n    \"\"\"\n    N = G.number_of_nodes()+first_label\n    if ordering == \"default\":\n        mapping = dict(zip(G.nodes(), range(first_label, N)))\n    elif ordering == \"sorted\":\n        nlist = G.nodes()\n        nlist.sort()\n        mapping = dict(zip(nlist, range(first_label, N)))\n    elif ordering == \"increasing degree\":\n        dv_pairs = [(d,n) for (n,d) in G.degree_iter()]\n        dv_pairs.sort() # in-place sort from lowest to highest degree\n        mapping = dict(zip([n for d,n in dv_pairs], range(first_label, N)))\n    elif ordering == \"decreasing degree\":\n        dv_pairs = [(d,n) for (n,d) in G.degree_iter()]\n        dv_pairs.sort() # in-place sort from lowest to highest degree\n        dv_pairs.reverse()\n        mapping = dict(zip([n for d,n in dv_pairs], range(first_label, N)))\n    else:\n        raise nx.NetworkXError('Unknown node ordering: %s'%ordering)\n    H = relabel_nodes(G, mapping)\n    H.name = \"(\"+G.name+\")_with_int_labels\"\n    # create node attribute with the old label\n    if label_attribute is not None:\n        nx.set_node_attributes(H, label_attribute,\n                               dict((v,k) for k,v in mapping.items()))\n    return H\n", "path": "networkx/relabel.py"}]}