import json


def get_map_node_to_team(match_config_path):
    
    """
    Returns a map of node_id to team_id from a match configuration JSON file
    (batch_input.json or freeplay.json).
    """
    
    node_to_team = {}
    
    with open(match_config_path) as config_file:
        config_json = json.loads(config_file.read())

    for node_info in config_json["NodeData"]:
        node_id = node_info["TrafficNode"]
        image = node_info.get("ImageName")
        is_incumbent = image and ("incumbent" in image or "observer" in image)

        if "team_no" in node_info and not is_incumbent:
            team_id = "Team" + str(node_info["team_no"])
        else:
            team_id = node_info["ImageName"]
            
        node_to_team[node_id] = team_id
        
    return node_to_team