def get_topological_order(G):
    """
    Use BFS to find the order of variables in a network.

    Parameters
    ----------
    G : Network (see network.py)
       The Bayesian network for which to calculate the order.

    Returns
    -------
    list of int 
       Features as node ID's (see network.py)
       Topological order of nodes in `G`.
    """

    # Use BFS to find the order of variables in the network
    queue = G.roots[:]
    visited = set()
    for root in queue:
        visited.add(root.data_id)
    X = []
    while queue:
        node = queue.pop(0)
        X.append(node.data_id)
        for new_node in node.children:
            if new_node.data_id not in visited and all(n in visited for n in new_node.parents):
                visited.add(new_node.data_id)
                queue.append(new_node)
    return X