def test_remove_node(self):
        """
        Test to ensure that nodes will be removed correctly
        """
        data = {
            "nodes": [
                {
                    "data": {
                        "id": "0"
                    }
                },
                {
                    "data": {
                        "id": "1"
                    }
                },
                {
                    "data": {
                        "id": "2"
                    }
                },
            ],
            "edges": [
                {
                    "data": {
                        "source": "0",
                        "target": "1"
                    }
                },
                {
                    "data": {
                        "source": "1",
                        "target": "2"
                    }
                },
                {
                    "data": {
                        "source": "2",
                        "target": "0"
                    }
                },
            ],
        }
        expected_nodes = [
            Node(data={"id": "1"}, position={}),
            Node(data={"id": "2"}, position={}),
        ]
        expected_edges = [
            Edge(classes="", data={
                "source": "1",
                "target": "2"
            }),
        ]

        graph = Graph()
        graph.add_graph_from_json(data)
        graph.remove_node(graph.nodes[0])
        compare_edges(expected_edges, graph.edges)
        compare_nodes(expected_nodes, graph.nodes)
    def test_remove_edge_by_id(self):
        """
        Test to ensure that edges will be removed given the ids of the nodes
        for different graphs
        """
        data = {
            "nodes": [
                {
                    "data": {
                        "id": "0"
                    }
                },
                {
                    "data": {
                        "id": "1"
                    }
                },
                {
                    "data": {
                        "id": "2"
                    }
                },
            ],
            "edges": [
                {
                    "data": {
                        "source": "0",
                        "target": "1",
                        "weight": "1"
                    }
                },
                {
                    "data": {
                        "source": "0",
                        "target": "1",
                        "weight": "2"
                    }
                },
                {
                    "data": {
                        "source": "1",
                        "target": "0"
                    }
                },
                {
                    "data": {
                        "source": "1",
                        "target": "2"
                    }
                },
                {
                    "data": {
                        "source": "2",
                        "target": "0"
                    }
                },
            ],
        }
        expected_nodes = [
            Node(data={"id": "0"}, position={}),
            Node(data={"id": "1"}, position={}),
            Node(data={"id": "2"}, position={}),
        ]
        expected_edges_undirected = [
            Edge(classes="", data={
                "source": "1",
                "target": "2"
            }),
            Edge(classes="", data={
                "source": "2",
                "target": "0"
            }),
        ]
        expected_edges_directed = [
            Edge(classes=" directed ", data={
                "source": "1",
                "target": "0"
            }),
            Edge(classes=" directed ", data={
                "source": "1",
                "target": "2"
            }),
            Edge(classes=" directed ", data={
                "source": "2",
                "target": "0"
            }),
        ]
        expected_edges_multiple = [
            Edge(classes=" multiple_edges ",
                 data={
                     "source": "1",
                     "target": "2"
                 }),
            Edge(classes=" multiple_edges ",
                 data={
                     "source": "2",
                     "target": "0"
                 }),
        ]

        graph = Graph()
        graph.add_graph_from_json(data)
        graph.remove_edge_by_id("0", "1")
        compare_edges(expected_edges_undirected, graph.edges)
        compare_nodes(expected_nodes, graph.nodes)

        graph = Graph()
        graph.add_graph_from_json(data, directed=True)
        graph.remove_edge_by_id("0", "1")
        compare_edges(expected_edges_directed, graph.edges)
        compare_nodes(expected_nodes, graph.nodes)
        graph.remove_edge_by_id("1", "0")
        compare_edges(expected_edges_directed[1:], graph.edges)
        compare_nodes(expected_nodes, graph.nodes)

        graph = Graph()
        graph.add_graph_from_json(data, multiple_edges=True)
        graph.remove_edge_by_id("0", "1")
        compare_edges(expected_edges_multiple, graph.edges)
        compare_nodes(expected_nodes, graph.nodes)
    def test_remove_edge(self):
        """
        Test to ensure that edges will be removed
        """
        # only a small test because everything else is covered in remove_edge_by_id()
        data = {
            "nodes": [
                {
                    "data": {
                        "id": "0"
                    }
                },
                {
                    "data": {
                        "id": "1"
                    }
                },
                {
                    "data": {
                        "id": "2"
                    }
                },
            ],
            "edges": [
                {
                    "data": {
                        "source": "0",
                        "target": "1"
                    }
                },
                {
                    "data": {
                        "source": "1",
                        "target": "2"
                    }
                },
                {
                    "data": {
                        "source": "2",
                        "target": "0"
                    }
                },
            ],
        }
        expected_nodes = [
            Node(data={"id": "0"}, position={}),
            Node(data={"id": "1"}, position={}),
            Node(data={"id": "2"}, position={}),
        ]
        expected_edges = [
            Edge(classes="", data={
                "source": "1",
                "target": "2"
            }),
            Edge(classes="", data={
                "source": "2",
                "target": "0"
            }),
        ]

        graph = Graph()
        graph.add_graph_from_json(data)
        graph.remove_edge(graph.edges[0])
        compare_edges(expected_edges, graph.edges)
        compare_nodes(expected_nodes, graph.nodes)