Changeset 10510:e65f85644182 in orange


Ignore:
Timestamp:
03/13/12 17:43:51 (2 years ago)
Author:
miha
Branch:
default
rebase_source:
4b5672932052f697bb634cca91743026714ec9d5
Message:

Fixed a bug in older versions of networkx.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/Unsupervised/OWNxAnalysis.py

    r10046 r10510  
    66<priority>6425</priority> 
    77""" 
     8from PyQt4.QtCore import QMutex 
    89import numpy 
    910import networkx as nx 
     
    6667        self.outputs = [("Network", Orange.network.Graph),  
    6768                        ("Items", Orange.data.Table)] 
    68      
     69 
    6970        self.methods = [ 
    7071            ("number_of_nodes", True, "Number of nodes", GRAPHLEVEL, lambda G: G.number_of_nodes()), 
     
    7576            ("average_shortest_path_length", False, "Average shortest path length", GRAPHLEVEL, nx.average_shortest_path_length), 
    7677            ("density", True, "Density", GRAPHLEVEL, nx.density), 
    77             ("degree_assortativity_coefficient", False, "Degree assortativity coefficient", GRAPHLEVEL, nx.degree_assortativity_coefficient), 
     78            ("degree_assortativity_coefficient", False, \ 
     79                "Degree assortativity coefficient", GRAPHLEVEL, \ 
     80                    nx.degree_assortativity_coefficient if \ 
     81                    hasattr(nx, "degree_assortativity_coefficient") else None), 
    7882            # additional attr needed 
    7983            #("attribute_assortativity_coefficient", False, "Attribute assortativity coefficient", GRAPHLEVEL, nx.attribute_assortativity_coefficient), 
    8084            #("numeric_assortativity_coefficient", False, "Numeric assortativity coefficient", GRAPHLEVEL, nx.numeric_assortativity_coefficient), 
    81             ("degree_pearson_correlation_coefficient", False, "Degree pearson correlation coefficient", GRAPHLEVEL, nx.degree_pearson_correlation_coefficient), 
    82             ("estrada_index", False, "Estrada index", GRAPHLEVEL, nx.estrada_index), 
     85            ("degree_pearson_correlation_coefficient", False, \ 
     86                "Degree pearson correlation coefficient", GRAPHLEVEL, \ 
     87                nx.degree_pearson_correlation_coefficient if\ 
     88                hasattr(nx, "degree_pearson_correlation_coefficient") else None), 
     89            ("estrada_index", False, "Estrada index", GRAPHLEVEL, \ 
     90                nx.estrada_index if hasattr(nx, "estrada_index") else None), 
    8391            ("graph_clique_number", False, "Graph clique number", GRAPHLEVEL, nx.graph_clique_number), 
    8492            ("graph_number_of_cliques", False, "Graph number of cliques", GRAPHLEVEL, nx.graph_number_of_cliques), 
     
    112120            ("current_flow_closeness_centrality", False, "Information centrality", NODELEVEL, nx.current_flow_closeness_centrality), 
    113121            ("current_flow_betweenness_centrality", False, "Random-walk betweenness centrality", NODELEVEL, nx.current_flow_betweenness_centrality), 
    114             ("approximate_current_flow_betweenness_centrality", False, "Approx. random-walk betweenness centrality", NODELEVEL, nx.approximate_current_flow_betweenness_centrality), 
     122            ("approximate_current_flow_betweenness_centrality", False, \ 
     123                "Approx. random-walk betweenness centrality", NODELEVEL, \ 
     124                nx.approximate_current_flow_betweenness_centrality if \ 
     125                hasattr(nx, "approximate_current_flow_betweenness_centrality") \ 
     126                    else None), 
    115127            ("eigenvector_centrality", False, "Eigenvector centrality", NODELEVEL, nx.eigenvector_centrality), 
    116128            ("eigenvector_centrality_numpy", False, "Eigenvector centrality (NumPy)", NODELEVEL, nx.eigenvector_centrality_numpy), 
     
    120132            ("closeness_vitality", False, "Closeness vitality", NODELEVEL, nx.closeness_vitality),                     
    121133        ] 
     134 
     135        self.methods = [method for method in self.methods if method[-1] is not None] 
    122136         
    123137        self.auto_commit = False 
Note: See TracChangeset for help on using the changeset viewer.