How to use the momepy.betweenness_centrality function in momepy

To help you get started, we’ve selected a few momepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github martinfleis / momepy / tests / test_graph.py View on Github external
def test_betweenness_centrality(self):
        net = mm.betweenness_centrality(self.network)
        net2 = mm.betweenness_centrality(self.network, mode="edges")
        angular = mm.betweenness_centrality(self.dual, weight="angle")
        with pytest.raises(ValueError):
            mm.betweenness_centrality(self.network, mode="nonexistent")
        node = 0.2413793103448276
        edge = 0.16995073891625617
        ang_b = 0.16470588235294117
        assert net.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == node
        assert (
            net2.edges[
                (1603226.9576840235, 6464160.158361825),
                (1603039.9632033885, 6464087.491175889),
                8,
            ]["betweenness"]
            == edge
        )
github martinfleis / momepy / tests / test_graph.py View on Github external
def test_betweenness_centrality(self):
        net = mm.betweenness_centrality(self.network)
        net2 = mm.betweenness_centrality(self.network, mode="edges")
        angular = mm.betweenness_centrality(self.dual, weight="angle")
        with pytest.raises(ValueError):
            mm.betweenness_centrality(self.network, mode="nonexistent")
        node = 0.2413793103448276
        edge = 0.16995073891625617
        ang_b = 0.16470588235294117
        assert net.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == node
        assert (
            net2.edges[
                (1603226.9576840235, 6464160.158361825),
                (1603039.9632033885, 6464087.491175889),
                8,
            ]["betweenness"]
            == edge
        )
        assert (
            angular.nodes[(1603315.3564306537, 6464044.376339891)]["betweenness"]
            == ang_b
        )
github martinfleis / momepy / tests / test_graph.py View on Github external
def test_betweenness_centrality(self):
        net = mm.betweenness_centrality(self.network)
        net2 = mm.betweenness_centrality(self.network, mode="edges")
        angular = mm.betweenness_centrality(self.dual, weight="angle")
        with pytest.raises(ValueError):
            mm.betweenness_centrality(self.network, mode="nonexistent")
        node = 0.2413793103448276
        edge = 0.16995073891625617
        ang_b = 0.16470588235294117
        assert net.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == node
        assert (
            net2.edges[
                (1603226.9576840235, 6464160.158361825),
                (1603039.9632033885, 6464087.491175889),
                8,
            ]["betweenness"]
            == edge
        )
        assert (
            angular.nodes[(1603315.3564306537, 6464044.376339891)]["betweenness"]
github martinfleis / momepy / tests / test_graph.py View on Github external
def test_betweenness_centrality(self):
        net = mm.betweenness_centrality(self.network)
        net2 = mm.betweenness_centrality(self.network, mode="edges")
        angular = mm.betweenness_centrality(self.dual, weight="angle")
        with pytest.raises(ValueError):
            mm.betweenness_centrality(self.network, mode="nonexistent")
        node = 0.2413793103448276
        edge = 0.16995073891625617
        ang_b = 0.16470588235294117
        assert net.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == node
        assert (
            net2.edges[
                (1603226.9576840235, 6464160.158361825),
                (1603039.9632033885, 6464087.491175889),
                8,
            ]["betweenness"]
            == edge
        )
        assert (
github martinfleis / momepy / tests / test_graph.py View on Github external
net2.edges[
                (1603226.9576840235, 6464160.158361825),
                (1603039.9632033885, 6464087.491175889),
                8,
            ]["betweenness"]
            == edge
        )
        assert (
            angular.nodes[(1603315.3564306537, 6464044.376339891)]["betweenness"]
            == ang_b
        )

        net = mm.betweenness_centrality(self.network, radius=5, weight=None)
        check = 53.74999999999999
        assert net.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == check
        net2 = mm.betweenness_centrality(
            self.network, radius=5, weight="mm_len", normalized=True
        )
        check2 = 0.21333333333333335
        assert (
            net2.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == check2
        )
github martinfleis / momepy / tests / test_graph.py View on Github external
ang_b = 0.16470588235294117
        assert net.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == node
        assert (
            net2.edges[
                (1603226.9576840235, 6464160.158361825),
                (1603039.9632033885, 6464087.491175889),
                8,
            ]["betweenness"]
            == edge
        )
        assert (
            angular.nodes[(1603315.3564306537, 6464044.376339891)]["betweenness"]
            == ang_b
        )

        net = mm.betweenness_centrality(self.network, radius=5, weight=None)
        check = 53.74999999999999
        assert net.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == check
        net2 = mm.betweenness_centrality(
            self.network, radius=5, weight="mm_len", normalized=True
        )
        check2 = 0.21333333333333335
        assert (
            net2.nodes[(1603650.450422848, 6464368.600601688)]["betweenness"] == check2
        )