Esempio n. 1
0
    def test_remap_node_ids_unweighted_graph_raises_warning(self):
        with warnings.catch_warnings(record=True) as warnings_context_manager:
            graph = nx.florentine_families_graph()

            gus.remap_node_ids(graph)

            self.assertEqual(len(warnings_context_manager), 1)
            self.assertTrue(
                issubclass(warnings_context_manager[0].category, UserWarning))
            self.assertTrue("Graph has at least one unweighted edge" in str(
                warnings_context_manager[0].message))
Esempio n. 2
0
    def test_remap_node_ids_graph_has_same_edges_but_remapped(self):
        graph = nx.Graph()

        graph.add_edge(0, 1, weight=10)
        graph.add_edge(1, "someid", weight=100)

        new_graph, new_node_ids = gus.remap_node_ids(graph)

        self._assert_graphs_are_equivalent(graph, new_graph, new_node_ids)
Esempio n. 3
0
    def test_remap_node_ids_invalid_typ_raises_typeerror(self):
        invalid_types = [str, int, list]

        for type in invalid_types:
            with pytest.raises(TypeError):
                gus.remap_node_ids(graph=type())