class_docstr: Class for performing pipeline structure exploration.
  The class allows you to convert pipelines into a networkx graph and considers
  all possible paths from primary PipelineNode (or primary PipelineNodes) to root node. If at least
  one of the paths contains an invalid sequence of operations, the search performed
  by this class will detect it
class_docstr_tok: ["Class","for","performing","pipeline","structure","exploration",".","The","class","allows","you","to","convert","pipelines","into","a","networkx","graph","and","considers","all","possible","paths","from","primary","PipelineNode","(","or","primary","PipelineNodes",")","to","root","node",".","If","at","least","one","of","the","paths","contains","an","invalid","sequence","of","operations",",","the","search","performed","by","this","class","will","detect","it"]
docstr: Based on predefined rules, the branch is checked for correctness.
  1) is_appropriate_operation
  2) is_independent_operation
  For example correct branch is:
      1) False -> True -> False
      2) True -> False -> False
      Data can be processed without errors due to wanted operation applied
      after independent operation
      True -> True -> after operation output everything is ok
  
  Incorrect branch is:
      1) False -> False -> True
      2) True -> False -> False
      Second operation is not wanted one and at the same time cannot
      process data without any transformation. So it will have an error
      True -> X False X -> True
  
  :param is_appropriate_operation: list with bool values is wanted operation placed in the node or not
  :param is_independent_operation: list with bool values is independent operation placed in the node or not
  :param path_len: length of list with graph nodes
docstr_tok: ["Based","on","predefined","rules",",","the","branch","is","checked","for","correctness",".","1",")","is_appropriate_operation","2",")","is_independent_operation","For","example","correct","branch","is",":","1",")","False","-",">","True","-",">","False","2",")","True","-",">","False","-",">","False","Data","can","be","processed","without","errors","due","to","wanted","operation","applied","after","independent","operation","True","-",">","True","-",">","after","operation","output","everything","is","ok","Incorrect","branch","is",":","1",")","False","-",">","False","-",">","True","2",")","True","-",">","False","-",">","False","Second","operation","is","not","wanted","one","and","at","the","same","time","can","not","process","data","without","any","transformation",".","So","it","will","have","an","error","True","-",">","X","False","X","-",">","True",":","param","is_appropriate_operation",":","list","with","bool","values","is","wanted","operation","placed","in","the","node","or","not",":","param","is_independent_operation",":","list","with","bool","values","is","independent","operation","placed","in","the","node","or","not",":","param","path_len",":","length","of","list","with","graph","nodes"]
code: def is_current_branch_correct(
      is_appropriate_operation, is_independent_operation, path_len
  ):
      """
      Based on predefined rules, the branch is checked for correctness.
      1) is_appropriate_operation
      2) is_independent_operation
      For example correct branch is:
          1) False -> True -> False
          2) True -> False -> False
          Data can be processed without errors due to wanted operation applied
          after independent operation
          True -> True -> after operation output everything is ok
  
      Incorrect branch is:
          1) False -> False -> True
          2) True -> False -> False
          Second operation is not wanted one and at the same time cannot
          process data without any transformation. So it will have an error
          True -> X False X -> True
  
      :param is_appropriate_operation: list with bool values is wanted operation placed in the node or not
      :param is_independent_operation: list with bool values is independent operation placed in the node or not
      :param path_len: length of list with graph nodes
      """
  
      # Check if operations were in the path
      is_appropriate_operation = np.array(is_appropriate_operation)
      # Number of True in list
      number_operations = is_appropriate_operation.sum()
  
      # True > 0 - so find ids with appropriate operations
      operation_ids = np.ravel(
          np.argwhere(is_appropriate_operation > 0)
      )
  
      # Find independent operations in the path
      if len(is_independent_operation) > 0:
          is_independent_operation = np.array(is_independent_operation)
      else:
          is_independent_operation = np.array([False] * path_len)
  
      # Check independent operation presence in path
      number_independent_operations = np.sum(is_independent_operation)
  
      # By default it is incorrect
      is_branch_correct = False
      if number_operations == 0 and number_independent_operations == 0:
          # Path contain non independent operations and have no good ones
          is_branch_correct = False
  
      elif number_operations > 0 and number_independent_operations == 0:
          # Path contain good operations but have no independent
          if operation_ids[0] == 0:
              # Wanted operation in the first place
              is_branch_correct = True
          else:
              is_branch_correct = False
  
      elif number_operations == 0 and number_independent_operations > 0:
          # Have no wanted operations but have independent operations
          if number_independent_operations == path_len:
              # All operations are independent
              is_branch_correct = True
          else:
              is_branch_correct = False
  
      elif number_operations > 0 and number_independent_operations > 0:
          # Have both independent operation(s) and wanted operations
          path_before_good_operation = is_independent_operation[
              : operation_ids[0]
          ]
          if path_before_good_operation.sum() == len(
              path_before_good_operation
          ):
              # All operations are independent before wanted operation applying
              is_branch_correct = True
          else:
              is_branch_correct = False
  
      return is_branch_correct
  
file_path: FEDOT/fedot/preprocessing/structure.py
imports: from typing import Tuple, List, Dict, Any
  import networkx
  import numpy
  import pandas
  from golem.core.dag.convert import graph_structure_as_nx_graph
label_desc: Use image node_id 5 for calling the PipelineStructureExplorer obj's underlying member method code with example usage: obj.is_current_branch_correct(is_appropriate_operation, is_independent_operation, path_len) and returns: is_branch_correct