#!/usr/bin/env python
from nose.tools import *
import networkx

class TestBetweennessCentrality:

    def setUp(self):

        G=networkx.Graph();
        G.add_edge(0,1,3)
        G.add_edge(0,2,2)
        G.add_edge(0,3,6)
        G.add_edge(0,4,4)
        G.add_edge(1,3,5)
        G.add_edge(1,5,5)
        G.add_edge(2,4,1)
        G.add_edge(3,4,2)
        G.add_edge(3,5,1)
        G.add_edge(4,5,4)
        self.G=G
        self.exact_weighted={0: 4.0, 1: 0.0, 2: 8.0, 3: 6.0, 4: 8.0, 5: 0.0}


    def test_brandes_betweenness(self):
        b=networkx.betweenness_centrality(self.G,weighted_edges=True,
                                          normalized=False)
        for n in sorted(self.G):
            assert_equal(b[n],self.exact_weighted[n])


    def test_load(self):
        b=networkx.load_centrality(self.G,weighted_edges=True,
                                   normalized=False)
        for n in sorted(self.G):
            assert_equal(b[n],self.exact_weighted[n])



Add betweeness centrality and load centrality test.
Add betweeness centrality and load centrality test.

--HG--
extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401110
