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: In the pipeline structure, a node with an operation with the appropriate tag is searched for.
  In this case the operations must have priority in the pipeline - in the primary Node or not far from it.
  
  Correct pipeline:
  operation with tag -> linear
  Incorrect pipeline:
  linear -> operation with tag
  
  :param pipeline: pipeline to check
  :param tag_to_check: find appropriate operation by desired tag
  (for example encoding or imputing)
  :param source_name: label of primary node for current input data. Set as 'default' if
  pipeline prepared for unimodal data
docstr_tok: ["In","the","pipeline","structure",",","a","node","with","an","operation","with","the","appropriate","tag","is","searched","for",".","In","this","case","the","operations","must","have","priority","in","the","pipeline","-","in","the","primary","Node","or","not","far","from","it",".","Correct","pipeline",":","operation","with","tag","-",">","linear","Incorrect","pipeline",":","linear","-",">","operation","with","tag",":","param","pipeline",":","pipeline","to","check",":","param","tag_to_check",":","find","appropriate","operation","by","desired","tag","(","for","example","encoding","or","imputing",")",":","param","source_name",":","label","of","primary","node","for","current","input","data",".","Set","as","'default","'","if","pipeline","prepared","for","unimodal","data"]
code: def check_structure_by_tag(
      pipeline: "Pipeline",
      tag_to_check: str,
      source_name: str = DEFAULT_SOURCE_NAME,
  ):
      """
      In the pipeline structure, a node with an operation with the appropriate tag is searched for.
      In this case the operations must have priority in the pipeline - in the primary Node or not far from it.
  
      Correct pipeline:
      operation with tag -> linear
      Incorrect pipeline:
      linear -> operation with tag
  
      :param pipeline: pipeline to check
      :param tag_to_check: find appropriate operation by desired tag
      (for example encoding or imputing)
      :param source_name: label of primary node for current input data. Set as 'default' if
      pipeline prepared for unimodal data
      """
      if len(pipeline.nodes) < 2:
          # Preprocessing needed for single-node pipeline
          return False
  
      graph, node_labels = graph_structure_as_nx_graph(pipeline)
  
      # Assign information for all nodes in the graph
      (
          graph,
          info_df,
      ) = PipelineStructureExplorer._enrich_with_information(
          graph, node_labels
      )
  
      primary_df = info_df[info_df["node_type"] == "primary"]
      root_df = info_df[info_df["node_type"] == "root"]
      root_id = root_df.iloc[0]["node_id"]
  
      paths = {}
      path_id = 0
      for i, node_info in primary_df.iterrows():
          primary_id = node_info["node_id"]
          node_name = node_info["node_label"].operation.operation_type
          if source_name in (node_name, DEFAULT_SOURCE_NAME):
              for path in nx.all_simple_paths(
                  graph, source=primary_id, target=root_id
              ):
                  # Check the path (branch) whether it has wanted operation in correct location or not
                  path_info = PipelineStructureExplorer.check_path(
                      graph, path, tag_to_check
                  )
                  paths[path_id] = path_info
                  path_id += 1
  
      correct_branches = (
          branch["correctness"] for branch in paths.values()
      )
      # 'False' means that least one branch in the graph cannot process desired type of data
      return all(correct_branches)
  
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 1 for calling the PipelineStructureExplorer obj's underlying member method code with example usage: obj.check_structure_by_tag(pipeline, tag_to_check, source_name) and returns: all, False