Changeset 9278:c7451ddd43ec in orange


Ignore:
Timestamp:
11/28/11 12:41:03 (2 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
bf1555bc5bf436b5e2dc570a3c70bc4e11346a76
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Visualize Qt/OWPubmedView.py

    r9256 r9278  
    6161            i = nodes.pop() 
    6262            subnet.node[i] = self._network.node[i] 
    63             neig = [x for x in self._network.neighbors(i) if x in nodes] #if net.edge[i][x]['weight'] > 0.5] 
     63            neig = [x for x in self._network.neighbors(i) if x in nodes]  
    6464            subnet.add_weighted_edges_from([(i,x,w) for x,w in zip(neig, [self._network.edge[i][y]['weight'] for y in neig])]) 
    6565         
     
    8989     
    9090    def node_selection_changed(self): 
    91         # selection --> delete_node/delete_node_and_neig/expand/set_score ? 
    9291        pass 
    9392     
     93    def set_user_node_score(self, node_index, new_score): 
     94        self._delta_score[node_index] = new_score - self._network.node[node_index]['score'] 
     95        self._network.node[node_index]['score'] = new_score 
     96        self._network.node[node_index]['user_score'] = 1 
     97     
    9498    def update_center_nodes(self, new_node): 
    95         self._center_nodes.append(new_node) 
    96          
    97          
     99        self._center_nodes.append(new_node)   
    98100         
    99101    def _get_neighbors(self): 
     
    109111    def _propagate(self, net): 
    110112        central_nodes = [i for i in net.nodes() if net.node[i]['user_score'] == 1] 
    111         central_delta_score = [delta_score[id] for id in central_nodes] 
     113        central_delta_score = [self._delta_score[id] for id in central_nodes] 
    112114        cluster_centers = [net.node[x]['cluster'] for x in central_nodes if net.node[x]['cluster'] != ''] 
    113115        updated = central_nodes[:] 
     
    123125                        predec = [j for j in net.neighbors(i) if j in central_nodes] 
    124126                        predec_delta_score = [central_delta_score[central_nodes.index(x)] for x in predec] 
    125                         self._k_algortihm = compute_k(i, cluster_centers, net) 
     127                        self._k_algortihm = self.compute_k(i, cluster_centers, net) 
    126128                        if self._k_algortihm: #else the node is isolated and the score doesn't change 
    127129                            net.node[i]['score'] = _prop(predec, predec_delta_score, i, L, net) 
     
    131133                central_delta_score = [] 
    132134                for id in central_nodes: 
    133                     if delta_score.get(id, []): 
    134                         central_delta_score.append(delta_score[id]) 
     135                    if self._delta_score.get(id, []): 
     136                        central_delta_score.append(self._delta_score[id]) 
    135137                    else: 
    136138                        central_delta_score.append(net.node[id]['score'] - 0.5) 
     
    139141                return net 
    140142                 
    141     def compute_k(id, centers, net): 
     143    def compute_k(self, id, centers, net): 
    142144        import networkx as nx #VEDERE SE C'E' IN ORANGENET  
    143145        if self._algorithm == 0: #no clustering 
     
    255257            self.inside_view._hidden_nodes.append(node.index()) 
    256258         
    257         else: 
    258             self.inside_view._network.node[node.index()]['user_score'] = 1 
    259             self.inside_view._delta_score[node.index()] = float(action.text()) - 0.5              
    260             self.inside_view._network.node[node.index()]['score'] = float(action.text()) 
     259        else:       
     260            self.inside_view.set_user_node_score(node.index(), float(action.text())) 
    261261         
    262262        self.inside_view.update_network()  #chiama propagate 
Note: See TracChangeset for help on using the changeset viewer.