def get_subgraph(G, attribute, attribute_value):

    """
    This function returns the subgraph of G with the attribute
    attribute_value.

    Input:
    ------
        G: networkx graph
        attribute: attribute of the nodes
        attribute_value: value of the attribute

    Output:
    -------
        subgraph: the subgraph of G with the attribute attribute_value
    """

    node_list = []

    for x, y in G.nodes(data=True):

        if y[attribute] == attribute_value:

            node_list.append(x)

    return G.subgraph(node_list)