diff options
author | Emilien Kofman <emilien.kofman@gmail.com> | 2015-10-05 18:59:16 +0200 |
---|---|---|
committer | Emilien Kofman <emilien.kofman@gmail.com> | 2015-10-05 18:59:16 +0200 |
commit | 77eaf107c7dc88c6844493a056227bd08183125c (patch) | |
tree | fbb12101a8e3e9b73ddeb23267183c262a2f76e0 | |
parent | 3e936486237ee7dcaf4cf3f3c8d0629e2c5f3539 (diff) | |
download | networkx-77eaf107c7dc88c6844493a056227bd08183125c.tar.gz |
Bugfix (or simplification) of the size method in the Graph class
-rw-r--r-- | networkx/classes/graph.py | 7 |
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. |