title: How to properly access edge properties in Networkx
body: <p>I have a graph G that I first construct all edges on by a set of rules, and then later I want to remove some of them randomly. (Each node has a property "label" and all edges have the weight property assigned when created.) </p>
  
  <p>I'm on Python 3.4.2 using Networkx 1.9.1.</p>
  
  <p>The following code is what I've been trying to do so far, where I intend to remove an edge from a node if its degree is above the threshold <em>max_degree</em>.</p>
  
  <pre><code>    import networkx as nx
      import random
  
      G = nx.Graph()
      #  ...rest of code, adding nodes and edges...
  
      # Remove undesired edges
      max_degree = 4
      for node in G.nodes():
          if nx.degree(G, node) &gt;= max_degree:
              node_edges = G.edges([node])
              edge_to_remove = random.choice(node_edges)
              #  Each edge is a tuple (u,v), 
              #  where u and v are nodes in G.
              edge_u = G.node[edge_to_remove[0]]
              edge_v = G.node[edge_to_remove[1]]
              weight_loss = edge_to_remove['weight']
              print("Removing edge (weight={2}) from {0} to {1}"
                      .format(edge_u['label'], edge_v['label'], weight_loss))
              G.remove_edges_from([edge_to_remove])
  </code></pre>
  
  <p>First of all, this does not work, and secondly my guts tells me this is messy and cumbersome. The <a href="http://networkx.github.io/documentation/latest/tutorial/tutorial.html#edge-attributes" rel="nofollow">tutorial</a> suggest that the following code is how to access edge properties. The documentation points to the tutorial, but I come short of this:</p>
  
  <pre><code>    #  From tutorial, accessing edge properties:
      G.add_edge(1, 2, weight=4.7)
      G[1][2]['weight'] = 4.7
      G.edge[1][2]['weight'] = 4s
  
      #  I'd expect adaption with my code  should be
      #  the following, but alas..
      weight_of_edge = G.edge[node_u][node_v]['weight']
  </code></pre>
  
  <p>Please, I'd welcome suggested solutions to my problem, or a better approach.</p>