Python networkx.pagerank_scipy() Examples

The following are 12 code examples of networkx.pagerank_scipy(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module networkx , or try the search function .
Example #1
Source File: graph_score_vectorizer.py    From Quadflor with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, method='degree', analyzer=NltkNormalizer().split_and_normalize):
        self.analyze = analyzer
        self.method = method
        self.methods_on_digraph = {'hits', 'pagerank', 'katz'}
        self._get_scores = {'degree': nx.degree, 'betweenness': nx.betweenness_centrality,
                            'pagerank': nx.pagerank_scipy, 'hits': self._hits, 'closeness': nx.closeness_centrality,
                            'katz': nx.katz_centrality}[method]
        # Add a new value when a new vocabulary item is seen
        self.vocabulary = defaultdict()
        self.vocabulary.default_factory = self.vocabulary.__len__ 
Example #2
Source File: test_pagerank.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_scipy_pagerank(self):
        G = self.G
        p = networkx.pagerank_scipy(G, alpha=0.9, tol=1.e-08)
        for n in G:
            assert_almost_equal(p[n], G.pagerank[n], places=4)
        personalize = dict((n, random.random()) for n in G)
        p = networkx.pagerank_scipy(G, alpha=0.9, tol=1.e-08,
                                    personalization=personalize)

        assert_raises(networkx.NetworkXError, networkx.pagerank_scipy, G,
                      max_iter=0) 
Example #3
Source File: test_pagerank.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_dangling_scipy_pagerank(self):
        pr = networkx.pagerank_scipy(self.G, dangling=self.dangling_edges)
        for n in self.G:
            assert_almost_equal(pr[n], self.G.dangling_pagerank[n], places=4) 
Example #4
Source File: test_pagerank.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def test_empty_scipy(self):
        G = networkx.Graph()
        assert_equal(networkx.pagerank_scipy(G), {}) 
Example #5
Source File: test_pagerank.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_scipy_pagerank(self):
        G = self.G
        p = networkx.pagerank_scipy(G, alpha=0.9, tol=1.e-08)
        for n in G:
            assert_almost_equal(p[n], G.pagerank[n], places=4)
        personalize = dict((n, random.random()) for n in G)
        p = networkx.pagerank_scipy(G, alpha=0.9, tol=1.e-08,
                                    personalization=personalize) 
Example #6
Source File: test_pagerank.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_scipy_pagerank_max_iter(self):
        networkx.pagerank_scipy(self.G, max_iter=0) 
Example #7
Source File: test_pagerank.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_dangling_scipy_pagerank(self):
        pr = networkx.pagerank_scipy(self.G, dangling=self.dangling_edges)
        for n in self.G:
            assert_almost_equal(pr[n], self.G.dangling_pagerank[n], places=4) 
Example #8
Source File: test_pagerank.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_empty_scipy(self):
        G = networkx.Graph()
        assert_equal(networkx.pagerank_scipy(G), {}) 
Example #9
Source File: test_pagerank.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_scipy_pagerank(self):
        G = self.G
        p = networkx.pagerank_scipy(G, alpha=0.9, tol=1.e-08)
        for n in G:
            assert_almost_equal(p[n], G.pagerank[n], places=4)
        personalize = dict((n, random.random()) for n in G)
        p = networkx.pagerank_scipy(G, alpha=0.9, tol=1.e-08,
                                    personalization=personalize) 
Example #10
Source File: test_pagerank.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_scipy_pagerank_max_iter(self):
        networkx.pagerank_scipy(self.G, max_iter=0) 
Example #11
Source File: test_pagerank.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_dangling_scipy_pagerank(self):
        pr = networkx.pagerank_scipy(self.G, dangling=self.dangling_edges)
        for n in self.G:
            assert_almost_equal(pr[n], self.G.dangling_pagerank[n], places=4) 
Example #12
Source File: test_pagerank.py    From aws-kube-codesuite with Apache License 2.0 5 votes vote down vote up
def test_empty_scipy(self):
        G = networkx.Graph()
        assert_equal(networkx.pagerank_scipy(G), {})