def predict(G, u, v):
     if G.is_directed():
         return sum(1 / log(G.degree(w))
                    for w in nx.directed_common_neighbors(G, u, v))
     else:
         return sum(1 / log(G.degree(w))
                    for w in nx.common_neighbors(G, u, v))
 def predict(G, u, v):
     if G.is_directed():
         return len(list(nx.directed_common_neighbors(
             G, u, v))) * (dict_ce[u][1] + dict_ce[v][2])
     else:
         return len(list(nx.common_neighbors(
             G, u, v))) * (dict_ce[u][0] + dict_ce[v][0])
 def predict(G, u, v):
     if G.is_directed():
         union_size = len(set(G._succ[u]) | set(G._pred[v]))
         if union_size == 0:
             return 0
         return len(list(nx.directed_common_neighbors(G, u,
                                                      v))) / union_size
     else:
         union_size = len(set(G[u]) | set(G[v]))
         if union_size == 0:
             return 0
         return len(list(nx.common_neighbors(G, u, v))) / union_size
 def predict(G, u, v):
     if G.is_directed():
         return sum(dict_ce[w][0]
                    for w in nx.directed_common_neighbors(G, u, v))
     else:
         return sum(dict_ce[w][0] for w in nx.common_neighbors(G, u, v))
 def predict(G, u, v):
     if G.is_directed():
         return len(list(nx.directed_common_neighbors(G, u, v)))
     else:
         return len(list(nx.common_neighbors(G, u, v)))