code: def test_legal_operations_titanic(self):
      start_model = BayesianNetwork(
          [
              ("Survived", "Sex"),
              ("Pclass", "Age"),
              ("Pclass", "Embarked"),
          ]
      )
      all_possible_edges = set(
          [
              (u, v)
              for u in start_model.nodes()
              for v in start_model.nodes()
          ]
      )
      legal_ops = self.est_titanic1._legal_operations(
          model=start_model,
          score=self.score_titanic1,
          structure_score=self.score_structure_prior,
          tabu_list=[],
          max_indegree=float("inf"),
          black_list=set(),
          white_list=all_possible_edges,
          fixed_edges=set(),
      )
      self.assertEqual(len(list(legal_ops)), 20)
  
      tabu_list = [
          ("-", ("Survived", "Sex")),
          ("-", ("Survived", "Pclass")),
          ("flip", ("Age", "Pclass")),
      ]
      legal_ops_tabu = self.est_titanic1._legal_operations(
          model=start_model,
          score=self.score_titanic1,
          structure_score=self.score_structure_prior,
          tabu_list=tabu_list,
          max_indegree=float("inf"),
          black_list=set(),
          white_list=all_possible_edges,
          fixed_edges=set(),
      )
      self.assertEqual(len(list(legal_ops_tabu)), 18)
  
      legal_ops_indegree = self.est_titanic1._legal_operations(
          model=start_model,
          score=self.score_titanic1,
          structure_score=self.score_structure_prior,
          tabu_list=[],
          max_indegree=1,
          black_list=set(),
          white_list=all_possible_edges,
          fixed_edges=set(),
      )
      self.assertEqual(len(list(legal_ops_indegree)), 11)
  
      legal_ops_both = self.est_titanic1._legal_operations(
          model=start_model,
          score=self.score_titanic1,
          structure_score=self.score_structure_prior,
          tabu_list=tabu_list,
          max_indegree=1,
          black_list=set(),
          white_list=all_possible_edges,
          fixed_edges=set(),
      )
  
      legal_ops_both_ref = {
          ("+", ("Embarked", "Survived")): 10.050632580087495,
          ("+", ("Survived", "Pclass")): 41.8886804654893,
          ("+", ("Age", "Survived")): -23.635716036430722,
          ("+", ("Pclass", "Survived")): 41.81314459373152,
          ("+", ("Sex", "Pclass")): 4.772261678791324,
          ("-", ("Pclass", "Age")): 11.546515590730905,
          ("-", ("Pclass", "Embarked")): -32.17148283253266,
          ("flip", ("Pclass", "Embarked")): 3.3563814191275583,
          ("flip", ("Survived", "Sex")): 0.0397370279797542,
      }
      self.assertSetEqual(
          set([op for op, score in legal_ops_both]),
          set(legal_ops_both_ref),
      )
      for op, score in legal_ops_both:
          self.assertAlmostEqual(score, legal_ops_both_ref[op])
  
file_path: pgmpy/pgmpy/tests/test_estimators/test_HillClimbSearch.py
imports: import unittest
  import numpy
  import pandas
  from pgmpy.estimators import HillClimbSearch, K2Score
  from pgmpy.models import BayesianNetwork
label_desc: Use image node_id 4 for calling the TestHillClimbEstimator obj's underlying member method code with example usage: obj.test_legal_operations_titanic() without return types