"""simple docstring"""




def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Optional[Any]    ,_lowerCamelCase		: Union[str, Any]			) ->   List[Any]:
  print("""\nThe shortest path matrix using Floyd Warshall algorithm\n"""			)
  for i in range(_lowerCamelCase			):
    for j in range(_lowerCamelCase			):
      if dist[i][j] != float("""inf"""			):
        print(int(dist[i][j]			)    ,end="""\t"""			)
      else:
        print("""INF"""    ,end="""\t"""			)
    print()





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: List[str]    ,_lowerCamelCase		: Union[str, Any]			) ->   str:
  _lowerCAmelCase		: List[str]						    =  [[float("""inf"""			) for _ in range(_lowerCamelCase			)] for _ in range(_lowerCamelCase			)]

  for i in range(_lowerCamelCase			):
    for j in range(_lowerCamelCase			):
      _lowerCAmelCase		: Any						    =  graph[i][j]

      # check vertex k against all other vertices (i, j)
  for k in range(_lowerCamelCase			):
    # looping through rows of graph array
    for i in range(_lowerCamelCase			):
      # looping through columns of graph array
      for j in range(_lowerCamelCase			):
        if (
            dist[i][k] != float("""inf"""			)
            and dist[k][j] != float("""inf"""			)
            and dist[i][k] + dist[k][j] < dist[i][j]
        ):
          _lowerCAmelCase		: List[str]						    =  dist[i][k] + dist[k][j]

  _print_dist(_lowerCamelCase    ,_lowerCamelCase			)
  return dist, v


if __name__ == "__main__":
     _a   :	Optional[Any] 					=     int(input('Enter number of vertices: '))
     _a   :	Dict 					=     int(input('Enter number of edges: '))

     _a   :	Any 					=     [[float('inf') for i in range(v)] for j in range(v)]

     for i in range(v):
          _a   :	int 					=     0.0

          # src and dst are indices that must be within the array size graph[e][v]
          # failure to follow this will result in an error
     for i in range(e):
          print('\nEdge ', i + 1)
          _a   :	Optional[Any] 					=     int(input('Enter source:'))
          _a   :	List[str] 					=     int(input('Enter destination:'))
          _a   :	Tuple 					=     float(input('Enter weight:'))
          _a   :	Tuple 					=     weight

     floyd_warshall(graph, v)

     # Example Input
     # Enter number of vertices: 3
     # Enter number of edges: 2

     # # generated graph from vertex and edge inputs
     # [[inf, inf, inf], [inf, inf, inf], [inf, inf, inf]]
     # [[0.0, inf, inf], [inf, 0.0, inf], [inf, inf, 0.0]]

     # specify source, destination and weight for edge #1
     # Edge  1
     # Enter source:1
     # Enter destination:2
     # Enter weight:2

     # specify source, destination and weight for edge #2
     # Edge  2
     # Enter source:2
     # Enter destination:1
     # Enter weight:1

     # # Expected Output from the vertice, edge and src, dst, weight inputs!!
     # 0		INF	INF
     # INF	0	2
     # INF	1	0





"""simple docstring"""




from __future__ import annotations

from collections import deque
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Any
@dataclass
class 		__A							:
     _UpperCamelCase							:    int
     _UpperCamelCase							:    Node | None	      =	None
     _UpperCamelCase							:    Node | None	      =	None







def 							SCREAMING_SNAKE_CASE  (    ) ->   Node | None:
  _lowerCAmelCase		: Tuple						    =  Node(1			)
  _lowerCAmelCase		: int						    =  Node(2			)
  _lowerCAmelCase		: int						    =  Node(3			)
  _lowerCAmelCase		: Any						    =  Node(4			)
  _lowerCAmelCase		: Dict						    =  Node(5			)
  return tree





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Node | None			) ->   list[int]:
  return [root.data, *preorder(root.left			), *preorder(root.right			)] if root else []





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Node | None			) ->   list[int]:
  return postorder(root.left			) + postorder(root.right			) + [root.data] if root else []





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Node | None			) ->   list[int]:
  return [*inorder(root.left			), root.data, *inorder(root.right			)] if root else []





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Node | None			) ->   int:
  return (max(height(root.left			)    ,height(root.right			)			) + 1) if root else 0





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Node | None			) ->   Sequence[Node | None]:
  _lowerCAmelCase		: list[Any]						    =  []

  if root is None:
    return output

  _lowerCAmelCase		: Union[str, Any]						    =  deque([root]			)

  while process_queue:
    _lowerCAmelCase		: Optional[Any]						    =  process_queue.popleft()
    output.append(node.data			)

    if node.left:
      process_queue.append(node.left			)
    if node.right:
      process_queue.append(node.right			)
  return output





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Node | None    ,_lowerCamelCase		: int			) ->   Sequence[Node | None]:
  _lowerCAmelCase		: list[Any]						    =  []

  def populate_output(_lowerCamelCase		: Node | None    ,_lowerCamelCase		: int			) -> None:
    if not root:
      return
    if level == 1:
      output.append(root.data			)
    elif level > 1:
      populate_output(root.left    ,level - 1			)
      populate_output(root.right    ,level - 1			)

  populate_output(_lowerCamelCase    ,_lowerCamelCase			)
  return output





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Node | None    ,_lowerCamelCase		: int			) ->   Sequence[Node | None]:
  _lowerCAmelCase		: list[Any]						    =  []

  def populate_output(_lowerCamelCase		: Node | None    ,_lowerCamelCase		: int			) -> None:
    if root is None:
      return
    if level == 1:
      output.append(root.data			)
    elif level > 1:
      populate_output(root.right    ,level - 1			)
      populate_output(root.left    ,level - 1			)

  populate_output(_lowerCamelCase    ,_lowerCamelCase			)
  return output





def 							SCREAMING_SNAKE_CASE  (    _lowerCamelCase		: Node | None			) ->   Sequence[Node | None] | list[Any]:
  if root is None:
    return []

  _lowerCAmelCase		: list[Sequence[Node | None]]						    =  []

  _lowerCAmelCase		: Tuple						    =  0
  _lowerCAmelCase		: Dict						    =  height(_lowerCamelCase			)

  for h in range(1    ,height_tree + 1			):
    if not flag:
      output.append(get_nodes_from_left_to_right(_lowerCamelCase    ,_lowerCamelCase			)			)
      _lowerCAmelCase		: Any						    =  1
    else:
      output.append(get_nodes_from_right_to_left(_lowerCamelCase    ,_lowerCamelCase			)			)
      _lowerCAmelCase		: Optional[int]						    =  0

  return output





def 							SCREAMING_SNAKE_CASE  (    ) ->   None:  # Main function for testing.
  _lowerCAmelCase		: int						    =  make_tree()
  print(f"In-order Traversal: {inorder(_lowerCamelCase			)}"			)
  print(f"Pre-order Traversal: {preorder(_lowerCamelCase			)}"			)
  print(f"Post-order Traversal: {postorder(_lowerCamelCase			)}"    ,"""\n"""			)

  print(f"Height of Tree: {height(_lowerCamelCase			)}"    ,"""\n"""			)

  print("""Complete Level Order Traversal: """			)
  print(level_order(_lowerCamelCase			)    ,"""\n"""			)

  print("""Level-wise order Traversal: """			)

  for level in range(1    ,height(_lowerCamelCase			) + 1			):
    print(f"Level {level}:"    ,get_nodes_from_left_to_right(_lowerCamelCase    ,level=_lowerCamelCase			)			)

  print("""\nZigZag order Traversal: """			)
  print(zigzag(_lowerCamelCase			)			)


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     main()




