Repository: networkx/networkx

Issue:
In `nx.closeness_centrality(G, distance='distance')` even though `distance` doesn't exist in the edge attribute dictionary, it doesn't raise any error or warning.
When I calculate the centrality of nodes in network, I use both weighted centrality and unweighted centrality. "Unweighted centrality" means that "all edges have same weight and distance". and "Weighted centrality" means their weights are different. 

The way to calculate them is easy like below. 

```python
# for unweighted centrality 
nx.closeness_centrality(G)
# for weighted centrality 
nx.closeness_centrality(G, distance='distance').items():
```

However, there is a small problem(or warning). 
In below simple code, 'distance' is not in edge attribute dictionary. But, I passed it `nx.closeness_centrality(G, distance='distance')` as argument. 
Even though `distance` doesn't exist in the edge attribute dictionary, it doesn't raise any error or warning. I don't know the weighted centrality wasn't calculated in the correct way. 

```python
import networkx as nx

G = nx.Graph()
G.add_edges_from([
    (0, 1, {'weight': 0.5}), (1, 2, {'weight': 0.2}), (2, 0, {'weight': 0.3}),])

print("== CLOSENESS CENTRALITY")
for k, v in nx.closeness_centrality(G).items():
    print(k, v)
print("== WEIGHTED CLOSENESS CENTRALITY")
# actually, key 'distance' doesn't exist in the edge attribute distionary. 
for k, v in nx.closeness_centrality(G, distance='distance').items():
    print(k, v)
print("=="*20)
```

The output is below. When the argument, 'distance' doesn't exist in edge attribute dictionary, it runs like Unweighted centrality. But, it doesn't make me know. I just think why two centrality are exactly and same, how it could be, for long time. This error makes me waste my effort.

```
== CLOSENESS CENTRALITY
0 1.0
1 1.0
2 1.0
== WEIGHTED CLOSENESS CENTRALITY
0 1.0
1 1.0
2 1.0
```

I think this is not an error but, it could make people confused. 
Therefore, when the argument name of `distance` doesn't exist in any edge attribute name, it would be better to raise warning message for users. 

If you feel that I am rude, it is because of my lack of english. Sorry. I don't want to hurt you. 
I always thanks for your help. I have used `networkx` a lot for my research. With your help, I've learned a lot. 







Discussion:
It looks like the problem stems from here:

https://github.com/networkx/networkx/blob/123fc2be585c6ebbf46b7fe876ba85dd34f92b2e/networkx/algorithms/shortest_paths/weighted.py#L76-L78

The use of the `get` method ignores missing keys and returns the default value of `1` instead. This is obviously not desirable in the case described above, where an error is appropriate. However, it looks like this behavior is relied upon in other contexts to set default values, so the fix isn't a no-brainer.

Resolving patch:
diff --git a/networkx/algorithms/centrality/closeness.py b/networkx/algorithms/centrality/closeness.py
--- a/networkx/algorithms/centrality/closeness.py
+++ b/networkx/algorithms/centrality/closeness.py
@@ -49,7 +49,9 @@ def closeness_centrality(G, u=None, distance=None, wf_improved=True):
 
     distance : edge attribute key, optional (default=None)
       Use the specified edge attribute as the edge distance in shortest
-      path calculations
+      path calculations.  If `None` (the default) all edges have a distance of 1.
+      Absent edge attributes are assigned a distance of 1. Note that no check
+      is performed to ensure that edges have the provided attribute.
 
     wf_improved : bool, optional (default=True)
       If True, scale by the fraction of nodes reachable. This gives the


Test patch: