Changeset 10495:d72cef4f468b in orange


Ignore:
Timestamp:
03/12/12 15:16:12 (2 years ago)
Author:
Lan Zagar <lan.zagar@…>
Branch:
default
rebase_source:
96b9129e9d7e511c7d6241e7d6b4f17e0b81997c
Message:

Quick bug fix for #1135, please review and improve if necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/OWNxHist.py

    r10046 r10495  
    256256            self.graph_matrix = matrix 
    257257 
    258         self.pconnected = self.graph.number_of_nodes() 
    259         self.nedges = self.graph.number_of_edges() 
     258        if self.graph is None: 
     259            self.pconnected = 0 
     260            self.nedges = 0 
     261        else: 
     262            self.pconnected = self.graph.number_of_nodes() 
     263            self.nedges = self.graph.number_of_edges() 
    260264        if hasattr(self, "infoa"): 
    261265            self.infoa.setText("Matrix size: %d" % self.matrix.dim) 
    262266        if hasattr(self, "infob"): 
    263             self.infob.setText("Graph nodes: %d (%3.1f%%)" % (self.pconnected, self.pconnected / float(self.matrix.dim) * 100)) 
     267            self.infob.setText("Graph nodes: %d (%3.1f%%)" % (self.pconnected, 
     268                self.pconnected / float(self.matrix.dim) * 100)) 
    264269        if hasattr(self, "infoc"): 
    265             self.infoc.setText("Graph edges: %d (%.2f edges/node)" % (self.nedges, self.nedges / float(self.pconnected))) 
     270            self.infoc.setText("Graph edges: %d (%.2f edges/node)" % ( 
     271                self.nedges, self.nedges / float(self.pconnected) 
     272                if self.pconnected else 0)) 
    266273 
    267274        #print 'self.graph:',self.graph+ 
Note: See TracChangeset for help on using the changeset viewer.