Commit 28169cb1 authored by Kelvinrr's avatar Kelvinrr
Browse files

added methods to the right branch this time

parent 5027f7ff
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
import itertools
import math
import os
import warnings

@@ -742,11 +741,10 @@ class CandidateGraph(nx.Graph):
            The number of edges or sum of edge weights in the graph.

        """
        s = sum(self.degree(weight=weight).values()) / 2
        if weight is None:
            return math.ceil(s)
        if weight:
            return sum(e[weight] for s, d, e in self.edges_iter(data=True))
        else:
            return s
            return len(self.edges())

    def create_node_subgraph(self, nodes):
        """
+9 −0
Original line number Diff line number Diff line
@@ -41,6 +41,15 @@ class TestCandidateGraph(unittest.TestCase):
        except:
            pass

    def test_size(self):
        graph = self.graph
        self.assertEqual(graph.size(), graph.number_of_edges())

        for u, v, e in graph.edges_iter(data=True):
            e['weight'] = 10

        self.assertEqual(graph.size('weight'), graph.number_of_edges()*10)

    def test_island_nodes(self):
        self.assertEqual(len(self.disconnected_graph.island_nodes()), 1)