wikipediascraper.py
def create_hc(G):
    """Creates hierarchical cluster of graph G from distance matrix"""
    path_length = nx.all_pairs_shortest_path_length(G)
    distances = numpy.zeros((len(G), len(G)))
    for u, p in path_length:
        for v, d in p.items():
            distances[u][v] = d
    # Create hierarchical cluster
    Y = distance.squareform(distances)
    Z = hierarchy.complete(Y)  # Creates HC using farthest point linkage
    # This partition selection is arbitrary, for illustrive purposes
    membership = list(hierarchy.fcluster(Z, t=1.15))
    # Create collection of lists for blockmodel
    partition = defaultdict(list)
    for n, p in zip(list(range(len(G))), membership):
        partition[p].append(n)
    return list(partition.values())
Creates hierarchical cluster of graph G from distance matrix
Creates hierarchical cluster of graph G from distance matrix
Creates hierarchical cluster of graph G from distance matrix
def create_hc(G):
    path_length = nx.all_pairs_shortest_path_length(G)
    distances = numpy.zeros((len(G), len(G)))
    for u, p in path_length:
        for v, d in p.items():
            distances[u][v] = d
    Y = distance.squareform(distances)
    Z = hierarchy.complete(Y)  
    membership = list(hierarchy.fcluster(Z, t=1.15))
    partition = defaultdict(list)
    for n, p in zip(list(range(len(G))), membership):
        partition[p].append(n)
    return list(partition.values())
def create_hc ( G ) : path_length = nx . all_pairs_shortest_path_length ( G ) distances = numpy . zeros ( ( len ( G ) , len ( G ) ) ) for u , p in path_length : for v , d in p . items ( ) : distances [ u ] [ v ] = d Y = distance . squareform ( distances ) Z = hierarchy . complete ( Y ) membership = list ( hierarchy . fcluster ( Z , t = 1.15 ) ) partition = defaultdict ( list ) for n , p in zip ( list ( range ( len ( G ) ) ) , membership ) : partition [ p ] . append ( n ) return list ( partition . values ( ) )
Creates hierarchical cluster of graph G from distance matrix
Creates hierarchical cluster of graph G from distance matrix
"""Creates hierarchical cluster of graph G from distance matrix""" # Create hierarchical cluster # Creates HC using farthest point linkage # This partition selection is arbitrary, for illustrive purposes # Create collection of lists for blockmodel
G