Ignore:
Timestamp:
06/04/12 08:29:58 (23 months ago)
Author:
mstajdohar
Branch:
default
rebase_source:
05ff7ac689329c6c9652373987be534dd579440d
Message:

Added random seed feature.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/network/community.py

    r10872 r10904  
    145145 
    146146def label_propagation(G, results2items=0, \ 
    147                       resultHistory2items=0, iterations=1000): 
     147                      resultHistory2items=0, iterations=1000, seed=None): 
    148148    """Label propagation for community detection, Raghavan et al., 2007 
    149149 
     
    163163 
    164164    """ 
     165 
     166    if seed is not None: 
     167        random.seed(seed) 
     168 
     169    vertices = sorted(G.nodes_iter()) 
     170    labels = dict(zip(vertices, range(G.number_of_nodes()))) 
    165171 
    166172    def next_label(neighbors): 
     
    174180        return [l for c, l in lbls if c >= m] 
    175181 
    176     vertices = G.nodes() 
    177     labels = dict(zip(vertices, range(G.number_of_nodes()))) 
    178182    lblhistory = [] 
    179183    for i in range(iterations): 
Note: See TracChangeset for help on using the changeset viewer.