def compute_g(algorithm, node, goal_state):
    """
        Evaluates the g() value.
        
        Parameters
        ===========
            algorithm: str
                The algorithm type based on which the g-value will be computed.
            node: Node
                The node whose g-value is to be computed.
            goal_state: State
                The goal state for the problem.
                
        Returns
        ========
            int
                The g-value for the node.
    """
    
    if algorithm == "bfs":
    
        return node.get_depth()
    
    if algorithm == "astar":
    
        return node.get_total_action_cost()

    elif algorithm == "gbfs":
        
        return 0

    elif algorithm == "ucs":
        
        return node.get_total_action_cost()

    elif algorithm == "custom-astar":
    
        return node.get_total_action_cost()
        
    # Should never reach here.
    assert False
    return float("inf")