import networkx as nx


def centrality(G):
    """
    Calculate information centrality for all nodes in the graph

    returns a graph with added node attributes"""

    cent = nx.degree_centrality(G)
    for node in G.nodes():
        G.nodes[node]["centrality"] = cent[node]

    return G