Changeset 8872:8c2eb16e09be in orange


Ignore:
Timestamp:
09/01/11 11:16:35 (3 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
8bbab968662cb269f33ae31df1ffdffc3a344336
Message:

Graph diameter inf and nan supported.

File:
1 edited

Legend:

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

    r8860 r8872  
    276276        OWGUI.label(ib, self, "Nodes per edge: %(verticesPerEdge).2f") 
    277277        OWGUI.label(ib, self, "Edges per node: %(edgesPerVertex).2f") 
    278         OWGUI.label(ib, self, "Diameter: %(diameter)i") 
     278        OWGUI.label(ib, self, "Diameter: %(diameter).0f") 
    279279        OWGUI.label(ib, self, "Clustering Coefficient: %(clustering_coefficient).1f%%") 
    280280         
     
    11441144        components = Orange.network.nx.algorithms.components.connected_components(undirected_graph) 
    11451145        if len(components) > 1: 
    1146             self.diameter = -1 
     1146            self.diameter = float('nan') 
    11471147        else: 
    1148             self.diameter = Orange.network.nx.algorithms.distance_measures.diameter(self.graph) 
     1148            try: 
     1149                self.diameter = Orange.network.nx.algorithms.distance_measures.diameter(self.graph) 
     1150            except Orange.network.nx.NetworkXError as err: 
     1151                if 'infinite path length' in err.message: 
     1152                    self.diameter = float('inf') 
     1153                else: 
     1154                    raise err 
    11491155             
    11501156        if self.graph.is_multigraph(): 
Note: See TracChangeset for help on using the changeset viewer.