summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilien Kofman <emilien.kofman@gmail.com>2015-10-05 18:59:16 +0200
committerEmilien Kofman <emilien.kofman@gmail.com>2015-10-05 18:59:16 +0200
commit77eaf107c7dc88c6844493a056227bd08183125c (patch)
treefbb12101a8e3e9b73ddeb23267183c262a2f76e0
parent3e936486237ee7dcaf4cf3f3c8d0629e2c5f3539 (diff)
downloadnetworkx-77eaf107c7dc88c6844493a056227bd08183125c.tar.gz
Bugfix (or simplification) of the size method in the Graph class
-rw-r--r--networkx/classes/graph.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/networkx/classes/graph.py b/networkx/classes/graph.py
index 7ea3b91c..fcdc7fd9 100644
--- a/networkx/classes/graph.py
+++ b/networkx/classes/graph.py
@@ -13,6 +13,7 @@ For directed graphs see DiGraph and MultiDiGraph.
# Pieter Swart <swart@lanl.gov>
# All rights reserved.
# BSD license.
+from __future__ import division
from copy import deepcopy
import networkx as nx
from networkx.exception import NetworkXError
@@ -1584,11 +1585,7 @@ class Graph(object):
>>> G.size(weight='weight')
6.0
"""
- s = sum(dict(self.degree(weight=weight)).values()) / 2
- if weight is None:
- return int(s)
- else:
- return float(s)
+ return sum(dict(self.degree(weight=weight)).values()) / 2
def number_of_edges(self, u=None, v=None):
"""Return the number of edges between two nodes.