def test_graph_with_no_edges(self):
        """Can still run even if the graph is without edges"""

        sm = StructureModel()
        nodes = [1, 2, 3]
        sm.add_nodes_from(nodes)
        sm.remove_edges_below_threshold(0.6)

        assert set(sm.nodes) == set(nodes)
        assert set(sm.edges) == set()
    def test_remove_edges_below_threshold(self):
        """Edges whose weight is less than a defined threshold should be removed"""

        sm = StructureModel()
        strong_edges = [(1, 2, 1.0), (1, 3, 0.8), (1, 5, 2.0)]
        weak_edges = [(1, 4, 0.4), (2, 3, 0.6), (3, 5, 0.5)]
        sm.add_weighted_edges_from(strong_edges)
        sm.add_weighted_edges_from(weak_edges)

        sm.remove_edges_below_threshold(0.7)

        assert set(sm.edges(data="weight")) == set(strong_edges)
    def test_negative_weights(self):
        """Negative edges whose absolute value is greater than the defined threshold should not be removed"""

        sm = StructureModel()
        strong_edges = [(1, 2, -3.0), (3, 1, 0.7), (1, 5, -2.0)]
        weak_edges = [(1, 4, 0.4), (2, 3, -0.6), (3, 5, -0.5)]
        sm.add_weighted_edges_from(strong_edges)
        sm.add_weighted_edges_from(weak_edges)

        sm.remove_edges_below_threshold(0.7)

        assert set(sm.edges(data="weight")) == set(strong_edges)
    def test_equal_weights(self):
        """Edges whose absolute value is equal to the defined threshold should not be removed"""

        sm = StructureModel()
        strong_edges = [(1, 2, 1.0), (1, 5, 2.0)]
        equal_edges = [(1, 3, 0.6), (2, 3, 0.6)]
        weak_edges = [(1, 4, 0.4), (3, 5, 0.5)]
        sm.add_weighted_edges_from(strong_edges)
        sm.add_weighted_edges_from(equal_edges)
        sm.add_weighted_edges_from(weak_edges)

        sm.remove_edges_below_threshold(0.6)

        assert set(sm.edges(data="weight")) == set.union(
            set(strong_edges), set(equal_edges))