コード例 #1
0
    def test_get_media_graph(self):
        db = self.db

        media = get_media_network(db=db,
                                  timespans_id=self.timespan['timespans_id'])
        graph = get_media_graph(media=media)

        assert len(graph.nodes) == len(self.all_media)
        assert len(graph.edges) == len(self.connected_media) - 1

        media_id_attributes = nx.get_node_attributes(graph, 'media_id').items()
        assert len(media_id_attributes) == len(self.all_media)
        for (node, media_id) in media_id_attributes:
            assert node == media_id

        name_attributes = nx.get_node_attributes(graph, 'name').items()
        assert len(name_attributes) == len(self.all_media)
        for (node, name) in name_attributes:
            assert len(name) > 0

        media_inlink_count_attributes = nx.get_node_attributes(
            graph, 'media_inlink_count').items()
        assert len(media_inlink_count_attributes) == len(self.all_media)
        for (node, count) in media_inlink_count_attributes:
            assert count > 0
コード例 #2
0
    def test_remove_platforms_from_graph(self):
        db = self.db

        media = get_media_network(db=db, timespans_id=self.timespan['timespans_id'])
        graph = get_media_graph(media=media)

        graph = remove_platforms_from_graph(graph=graph, platform_media_ids=[self.disconnected_media[0]['media_id'], ])

        assert len(graph.nodes) == len(self.all_media) - 1

        assert self.disconnected_media[0]['media_id'] not in graph.nodes
コード例 #3
0
    def test_get_giant_component(self):
        db = self.db

        media = get_media_network(db=db,
                                  timespans_id=self.timespan['timespans_id'])
        graph = get_media_graph(media=media)

        assert len(graph.nodes) == len(self.all_media)

        graph = get_giant_component(graph=graph)

        assert len(graph.nodes) == len(self.connected_media)
コード例 #4
0
    def test_prune_graph_by_distance(self):
        db = self.db

        media = get_media_network(db=db,
                                  timespans_id=self.timespan['timespans_id'])
        graph = get_media_graph(media=media)

        assert len(graph.nodes) == len(self.all_media)

        run_fa2_layout(graph=graph, memory_limit_mb=512)

        graph = prune_graph_by_distance(graph=graph)

        assert len(graph.nodes) == len(self.connected_media)