mst/bfs.py
def __trace_path(self,parent,start,end=None):
        """
        This method traces back the path to find the end node by utilizing a dictionary `parent`, whose values
        are the parent nodes to the keys. Specifically, the method:
        1. Initiates a list, `path`, with only the end node inside the list.
        While the last item in the list `path` is not the start node:
        2. Finds the parent of the end node by accessing `parent` using the end node as a key.
        3. Appending the parent of the end node to the end of `path`
        4. While loop exits if the parent of the end node is the start node
        5. Otherwise, the next parent node is found by accessing `parent` using the most recent node (found at the end of `path`)
        6. Append that parent node to `path`
        7. While loop exits if that parent node is the start node
        8. Repeat 5-8 until start node is added to the end of `path`
        9. Reverse `path` from having the order end-> start to having the order start->end
        
        If end == None, there is no path, and this method will return None. However, if end == None,
        this method will never be called because the `bfs` method only calls __trace_path once the end node was found.
    
        
        This method is only meant to be accessed from within the bfs method

        """
        if end: #True if end != None
            path = [end] #if there was an end node, initialize the list with it inside.
            
            while path[-1] != start: #once path contains all nodes from end->start exit the loop
                parent_node = parent[path[-1]] #Parent node of the key is the value returned
                path.append(parent_node)
            return path[::-1]

        This method traces back the path to find the end node by utilizing a dictionary `parent`, whose values
        are the parent nodes to the keys. Specifically, the method:
        1. Initiates a list, `path`, with only the end node inside the list.
        While the last item in the list `path` is not the start node:
        2. Finds the parent of the end node by accessing `parent` using the end node as a key.
        3. Appending the parent of the end node to the end of `path`
        4. While loop exits if the parent of the end node is the start node
        5. Otherwise, the next parent node is found by accessing `parent` using the most recent node (found at the end of `path`)
        6. Append that parent node to `path`
        7. While loop exits if that parent node is the start node
        8. Repeat 5-8 until start node is added to the end of `path`
        9. Reverse `path` from having the order end-> start to having the order start->end
        
        If end == None, there is no path, and this method will return None. However, if end == None,
        this method will never be called because the `bfs` method only calls __trace_path once the end node was found.
    
        
        This method is only meant to be accessed from within the bfs method

        
This method traces back the path to find the end node by utilizing a dictionary `parent`, whose values
are the parent nodes to the keys. Specifically, the method:
1. Initiates a list, `path`, with only the end node inside the list.
While the last item in the list `path` is not the start node:
2. Finds the parent of the end node by accessing `parent` using the end node as a key.
3. Appending the parent of the end node to the end of `path`
4. While loop exits if the parent of the end node is the start node
5. Otherwise, the next parent node is found by accessing `parent` using the most recent node (found at the end of `path`)
6. Append that parent node to `path`
7. While loop exits if that parent node is the start node
8. Repeat 5-8 until start node is added to the end of `path`
9. Reverse `path` from having the order end-> start to having the order start->end

If end == None, there is no path, and this method will return None. However, if end == None,
this method will never be called because the `bfs` method only calls __trace_path once the end node was found.

This method is only meant to be accessed from within the bfs method
This method traces back the path to find the end node by utilizing a dictionary ` parent ` whose values are the parent nodes to the keys . Specifically the method : 1 . Initiates a list ` path ` with only the end node inside the list . While the last item in the list ` path ` is not the start node : 2 . Finds the parent of the end node by accessing ` parent ` using the end node as a key . 3 . Appending the parent of the end node to the end of ` path ` 4 . While loop exits if the parent of the end node is the start node 5 . Otherwise the next parent node is found by accessing ` parent ` using the most recent node ( found at the end of ` path ` ) 6 . Append that parent node to ` path ` 7 . While loop exits if that parent node is the start node 8 . Repeat 5 - 8 until start node is added to the end of ` path ` 9 . Reverse ` path ` from having the order end - > start to having the order start - > end If end == None there is no path and this method will return None . However if end == None this method will never be called because the ` bfs ` method only calls __trace_path once the end node was found . This method is only meant to be accessed from within the bfs method
def __trace_path(self,parent,start,end=None):
        if end: 
            path = [end] 
            while path[-1] != start: 
                parent_node = parent[path[-1]] 
                path.append(parent_node)
            return path[::-1]
def __trace_path ( self , parent , start , end = None ) : if end : path = [ end ] while path [ - 1 ] != start : parent_node = parent [ path [ - 1 ] ] path . append ( parent_node ) return path [ : : - 1 ]
This method traces back the path to find the end node by utilizing a dictionary `parent`, whose values
are the parent nodes to the keys.
This method traces back the path to find the end node by utilizing a dictionary ` parent ` whose values are the parent nodes to the keys .
"""
        This method traces back the path to find the end node by utilizing a dictionary `parent`, whose values
        are the parent nodes to the keys. Specifically, the method:
        1. Initiates a list, `path`, with only the end node inside the list.
        While the last item in the list `path` is not the start node:
        2. Finds the parent of the end node by accessing `parent` using the end node as a key.
        3. Appending the parent of the end node to the end of `path`
        4. While loop exits if the parent of the end node is the start node
        5. Otherwise, the next parent node is found by accessing `parent` using the most recent node (found at the end of `path`)
        6. Append that parent node to `path`
        7. While loop exits if that parent node is the start node
        8. Repeat 5-8 until start node is added to the end of `path`
        9. Reverse `path` from having the order end-> start to having the order start->end
        
        If end == None, there is no path, and this method will return None. However, if end == None,
        this method will never be called because the `bfs` method only calls __trace_path once the end node was found.
    
        
        This method is only meant to be accessed from within the bfs method

        """ #True if end != None #if there was an end node, initialize the list with it inside. #once path contains all nodes from end->start exit the loop #Parent node of the key is the value returned
self
parent
start
end