mst/graph.py
def add_edges_to_pq(pq,start_node):
            '''
            pq: priority queue to which outgoing edges will be added
            start_node: All edges from this node will be found and added to the priority queue

            This function adds a tuple to the heap (priority queue) of the form (weight, start_node, destination_node)

            Strategy:
            1. Find neighboring nodes of start node that form an edge (weight >0)
                1a. This is done by indexing the row corresponding to the start node in the adjacency matrix, and looking for indices in that row where the value > 0 
                1b. Those elements are the neighbors that form an edge with the source node
            2. Add the tuple containing (weight, start_node index, neighbor index) to the priority queue

            '''

            for neighbor in np.argwhere(self.adj_mat[start_node]>0):#find neighboring nodes of start node by finding what other nodes form an edge of weight >0 with the start node. Iterate through those neighbors

                neighbor = neighbor[0]#index of neighbor in adjacency matrix is returned in a list of length 1 after using np.argwhere. Get the actual value by indexing it out.  
                heapq.heappush(priority_queue,(self.adj_mat[start_node,neighbor],start_node,neighbor))

            pq: priority queue to which outgoing edges will be added
            start_node: All edges from this node will be found and added to the priority queue

            This function adds a tuple to the heap (priority queue) of the form (weight, start_node, destination_node)

            Strategy:
            1. Find neighboring nodes of start node that form an edge (weight >0)
                1a. This is done by indexing the row corresponding to the start node in the adjacency matrix, and looking for indices in that row where the value > 0 
                1b. Those elements are the neighbors that form an edge with the source node
            2. Add the tuple containing (weight, start_node index, neighbor index) to the priority queue

            
priority queue to which outgoing edges will be added
start_node: All edges from this node will be found and added to the priority queue

This function adds a tuple to the heap (priority queue) of the form (weight, start_node, destination_node)

1. Find neighboring nodes of start node that form an edge (weight >0)
1a. This is done by indexing the row corresponding to the start node in the adjacency matrix, and looking for indices in that row where the value > 0
1b. Those elements are the neighbors that form an edge with the source node
2. Add the tuple containing (weight, start_node index, neighbor index) to the priority queue
priority queue to which outgoing edges will be added start_node : All edges from this node will be found and added to the priority queue This function adds a tuple to the heap ( priority queue ) of the form ( weight start_node destination_node ) 1 . Find neighboring nodes of start node that form an edge ( weight > 0 ) 1a . This is done by indexing the row corresponding to the start node in the adjacency matrix and looking for indices in that row where the value > 0 1b . Those elements are the neighbors that form an edge with the source node 2 . Add the tuple containing ( weight start_node index neighbor index ) to the priority queue
def add_edges_to_pq(pq,start_node):
            for neighbor in np.argwhere(self.adj_mat[start_node]>0):
                neighbor = neighbor[0]
                heapq.heappush(priority_queue,(self.adj_mat[start_node,neighbor],start_node,neighbor))
def add_edges_to_pq ( pq , start_node ) : for neighbor in np . argwhere ( self . adj_mat [ start_node ] > 0 ) : neighbor = neighbor [ 0 ] heapq . heappush ( priority_queue , ( self . adj_mat [ start_node , neighbor ] , start_node , neighbor ) )
pq: priority queue to which outgoing edges will be added
start_node: All edges from this node will be found and added to the priority queue
pq : priority queue to which outgoing edges will be added start_node : All edges from this node will be found and added to the priority queue
'''
            pq: priority queue to which outgoing edges will be added
            start_node: All edges from this node will be found and added to the priority queue

            This function adds a tuple to the heap (priority queue) of the form (weight, start_node, destination_node)

            Strategy:
            1. Find neighboring nodes of start node that form an edge (weight >0)
                1a. This is done by indexing the row corresponding to the start node in the adjacency matrix, and looking for indices in that row where the value > 0 
                1b. Those elements are the neighbors that form an edge with the source node
            2. Add the tuple containing (weight, start_node index, neighbor index) to the priority queue

            ''' #find neighboring nodes of start node by finding what other nodes form an edge of weight >0 with the start node. Iterate through those neighbors #index of neighbor in adjacency matrix is returned in a list of length 1 after using np.argwhere. Get the actual value by indexing it out.  
pq
start_node