コード例 #1
0
    def compute_features(self):
        # k = 1
        self.add_feature(
            "rich_club_k_1",
            rich_club_k_1,
            "The rich-club coefficient is the ratio of the number of actual to the \
            number of potential edges for nodes with degree greater than k",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "rich_club_k_max",
            rich_club_k_max,
            "The rich-club coefficient is the ratio of the number of actual to the number \
            of potential edges for nodes with degree greater than k",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "rich_club_maxminratio",
            rich_club_maxminratio,
            "The ratio of the smallest to largest rich club coefficients",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "rich_club",
            eval_rich_club,
            "The distribution of rich club coefficients",
            InterpretabilityScore(4),
            statistics="centrality",
        )
コード例 #2
0
    def compute_features(self):
        self.add_feature(
            "num_cycles",
            num_cycles,
            "The total number of cycles in the graph",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "average_cycle_length",
            average_cycle_length,
            "The average length of cycles in the graph",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "minimum_cycle_length",
            minimum_cycle_length,
            "The minimum length of cycles in the graph",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "ratio_nodes_cycle",
            ratio_nodes_cycle,
            "The ratio of nodes that appear in at least one cycle to the total number of nodes",
            InterpretabilityScore(3),
        )
コード例 #3
0
    def compute_features(self):

        self.add_feature(
            "node_conn",
            node_conn,
            "Node connectivity (statistics)",
            InterpretabilityScore("max") - 1,
            statistics="centrality",
        )

        # Calculate connectivity
        self.add_feature(
            "node_connectivity",
            nx.node_connectivity,
            "Node connectivity",
            InterpretabilityScore("max") - 1,
        )
        self.add_feature(
            "avg_node_connectivity",
            nx.average_node_connectivity,
            "Average node connectivity",
            InterpretabilityScore("max") - 1,
        )
        self.add_feature(
            "edge_connectivity",
            nx.edge_connectivity,
            "Edge connectivity",
            InterpretabilityScore("max") - 1,
        )
コード例 #4
0
    def compute_features(self):

        # checking if eulerian
        self.add_feature(
            "eulerian",
            nx.is_eulerian,
            "A graph is eulerian if it has a eulerian circuit: a closed walk that includes \
            each edges of the graph exactly once",
            InterpretabilityScore(3),
        )

        # checking if semi eulerian
        self.add_feature(
            "semi_eulerian",
            nx.is_semieulerian,
            "A graph is semi eulerian if it has a eulerian path but no eulerian circuit",
            InterpretabilityScore(3),
        )

        # checking if eulerian path exists
        self.add_feature(
            "semi_eulerian",
            nx.has_eulerian_path,
            "Whether a eulerian path exists in the network",
            InterpretabilityScore(3),
        )
コード例 #5
0
    def compute_features(self):

        self.add_feature(
            "num_triangles",
            triang,
            "Number of triangles in the graph",
            InterpretabilityScore("max"),
        )

        self.add_feature(
            "transitivity",
            nx.transitivity,
            "Transitivity of the graph",
            InterpretabilityScore("max"),
        )

        # Average clustering coefficient
        self.add_feature(
            "clustering",
            clustering_dist,
            "the clustering of the graph",
            InterpretabilityScore("max"),
            statistics="centrality",
        )

        # generalised degree
        self.add_feature(
            "square_clustering",
            square_clustering_dist,
            "the square clustering of the graph",
            InterpretabilityScore("max"),
            statistics="centrality",
        )
コード例 #6
0
    def compute_features(self):
        # add unweighted features
        self.add_feature(
            "num_communities",
            num_communities,
            "Number of communities",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "largest_commsize",
            largest_commsize,
            "The ratio of the largest and second largest communities using greedy modularity",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "ratio_commsize_maxmin",
            ratio_commsize_maxmin,
            "The ratio of the largest and second largest communities using greedy modularity",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "communities",
            eval_modularity,
            "The optimal partition using greedy modularity algorithm",
            InterpretabilityScore(3),
            statistics="clustering",
        )

        # add weighted features
        self.add_feature(
            "num_communities_weighted",
            num_communities_weighted,
            "Number of communities",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "largest_commsize_weighted",
            largest_commsize_weighted,
            "The ratio of the largest and second largest communities using greedy modularity",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "ratio_commsize_maxmin_weighted",
            ratio_commsize_maxmin_weighted,
            "The ratio of the largest and second largest communities using greedy modularity",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "communities_weighted",
            partial(eval_modularity, weight="weight"),
            "The optimal partition using greedy modularity algorithm",
            InterpretabilityScore(3),
            statistics="clustering",
        )
コード例 #7
0
    def compute_features(self):

        self.add_feature(
            "min_node_cut_size",
            min_node_cut_size,
            "Minimum node cut size",
            InterpretabilityScore("max"),
        )

        self.add_feature(
            "min_edge_cut_size",
            min_edge_cut_size,
            "Minimum edge cut size",
            InterpretabilityScore("max"),
        )
コード例 #8
0
    def compute_features(self):
        self.add_feature(
            "number_simple_cycles",
            number_simple_cycles,
            "A simple closed path with no repeated nodes (except the first)",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "simple_cycles_sizes",
            simple_cycles_sizes,
            "the distribution of simple cycle lengths",
            InterpretabilityScore(3),
            statistics="centrality",
        )
コード例 #9
0
    def compute_features(self):
        self.add_feature(
            "largest_commsize",
            largest_commsize,
            "The ratio of the largest and second largest communities using bisection algorithm",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "partition",
            eval_bisection,
            "The optimal partition for kernighan lin bisection algorithm",
            InterpretabilityScore(4),
            statistics="clustering",
        )
コード例 #10
0
ファイル: flow_hierarchy.py プロジェクト: Ben-Girard/hcga
    def compute_features(self):

        # graph clique number
        self.add_feature(
            "flow_hierarchy",
            nx.flow_hierarchy,
            "fraction of edges not participating in cycles",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "flow_hierarchy_weighted",
            partial(nx.flow_hierarchy, weight="weight"),
            "fraction of edges not participating in cycles",
            InterpretabilityScore(3),
        )
コード例 #11
0
ファイル: covering.py プロジェクト: Ben-Girard/hcga
    def compute_features(self):

        self.add_feature(
            "min_edge_cover",
            min_edge_cover,
            "The number of edges which consistutes the minimum edge cover of the graph",
            InterpretabilityScore(3),
        )
コード例 #12
0
    def compute_features(self):

        self.add_feature(
            "size_max_indep_set",
            size_max_indep_set,
            "The number of nodes in the maximal independent set",
            InterpretabilityScore(3),
        )
コード例 #13
0
    def compute_features(self):

        self.add_feature(
            "connectance",
            nx.density,
            "ratio of number of edges to maximum possible number of edges",
            InterpretabilityScore(3),
        )
コード例 #14
0
 def compute_features(self):
     self.add_feature(
         "Hits",
         hits,
         "Hits algorithm",
         InterpretabilityScore(3),
         statistics="centrality",
     )
コード例 #15
0
ファイル: nestedness.py プロジェクト: Ben-Girard/hcga
    def compute_features(self):

        self.add_feature(
            "nestedness",
            nestedness,
            "A measure of the nested structure of the network",
            InterpretabilityScore(3),
        )
コード例 #16
0
    def compute_features(self):

        # local effiency
        self.add_feature(
            "local_efficiency",
            nx.local_efficiency,
            "The local efficiency",
            InterpretabilityScore(4),
        )

        # global effiency
        self.add_feature(
            "global_efficiency",
            nx.global_efficiency,
            "The global efficiency",
            InterpretabilityScore(4),
        )
コード例 #17
0
    def compute_features(self):

        self.add_feature(
            "maximal_matching",
            maximal_matching,
            "Maximal matching",
            InterpretabilityScore(4),
        )
コード例 #18
0
    def compute_features(self):

        # omega metric
        self.add_feature(
            "omega",
            nx.omega,
            "The small world coefficient omega",
            InterpretabilityScore(4),
        )
コード例 #19
0
    def compute_features(self):

        # graph clique number
        self.add_feature(
            "reciprocity",
            nx.overall_reciprocity,
            "fraction of edges pointing in both directions to total number of edges",
            InterpretabilityScore(3),
        )
コード例 #20
0
    def compute_features(self):

        self.add_feature(
            "clique_sizes",
            clique_sizes,
            "the distribution of clique sizes",
            InterpretabilityScore(3),
            statistics="centrality",
        )
コード例 #21
0
    def compute_features(self):

        # s metric
        self.add_feature(
            "s_metric",
            partial(nx.s_metric, normalized=False),
            "Sum of the products deg(u)*deg(v) for every edge (u,v) in G",
            InterpretabilityScore(4),
        )
コード例 #22
0
    def compute_features(self):

        self.add_feature(
            "core number",
            core_number,
            "The core number distribution",
            InterpretabilityScore(5),
            statistics="centrality",
        )
コード例 #23
0
    def compute_features(self):
        num_communities = np.linspace(2, 10, 5)
        for num_comms in num_communities:
            self.add_feature(
                "sum_density_c={}".format(num_comms),
                partial(sum_density, num_comms=num_comms),
                "The total density of communities after fluid optimisations for c={}"
                .format(num_comms),
                InterpretabilityScore(3),
            )

            self.add_feature(
                "ratio_density_c={}".format(num_comms),
                partial(ratio_density, num_comms=num_comms),
                "The ratio density of communities after fluid optimisations for c={}"
                .format(num_comms),
                InterpretabilityScore(3),
            )
            self.add_feature(
                "len_most_dense_c={}".format(num_comms),
                partial(len_most_dense, num_comms),
                "The length of the most dense community after fluid optimisations for c={}"
                .format(num_comms),
                InterpretabilityScore(4),
            )

            self.add_feature(
                "len_least_dense_c={}".format(num_comms),
                partial(len_least_dense, num_comms),
                "The length of the least dense community after fluid optimisations for c={}"
                .format(num_comms),
                InterpretabilityScore(4),
            )

            # computing clustering quality
            self.add_feature(
                "partition_c={}".format(num_comms),
                partial(partitions, num_comms),
                "The optimal partition after fluid optimisations for c={}".
                format(num_comms),
                InterpretabilityScore(4),
                statistics="clustering",
            )
コード例 #24
0
    def compute_features(self):

        # distribution of vitality
        self.add_feature(
            "vitality",
            vitality,
            "The closeness vitality of a node is the change in the sum of distances between \
            all node pairs when excluding that node",
            InterpretabilityScore(3),
            statistics="centrality",
        )
コード例 #25
0
    def compute_features(self):

        self.add_feature(
            "in_degree",
            in_degree,
            "The distribution of in degrees of each node",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        self.add_feature(
            "in_degree_normed",
            in_deg_n,
            "The distribution of the ratio of in and total degrees of each node",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        self.add_feature(
            "out_degree",
            out_degree,
            "The distribution of out degrees of each node",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        self.add_feature(
            "out_degree_normed",
            out_deg_n,
            "The distribution of the ratio of out and total degrees of each node",
            InterpretabilityScore(3),
            statistics="centrality",
        )
        self.add_feature(
            "in_out_degree",
            in_out_deg,
            "The distribution of the ratio of in and out degrees of each node",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        self.add_feature(
            "in_degree_centrality",
            in_degree_centrality,
            "The distribution of in degree centralities",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        self.add_feature(
            "out_degree_centrality",
            out_degree_centrality,
            "The distribution of out degree centralities",
            InterpretabilityScore(3),
            statistics="centrality",
        )
コード例 #26
0
    def compute_features(self):

        # the longest path for each node
        self.add_feature(
            "largest_shortest_path",
            largest_shortest_path,
            "For each node we compute the shortest paths to every other node. \
            We then find the longest 'shortest path' for each node.",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        # the mean shortest path for each node
        self.add_feature(
            "mean_shortest_path",
            mean_shortest_path,
            "For each node we compute the shortest paths to every other node. \
            We then find the mean of the 'shortest paths' for each node.",
            InterpretabilityScore(3),
            statistics="centrality",
        )
        self.add_feature(
            "number_shortest_paths_directed",
            number_shortest_paths_directed,
            "the number of shortest paths (not counting paths of infinite length)",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "shortest_paths_length_directed",
            shortest_paths,
            "the number of shortest path lengths (not counting paths of infinite length)",
            InterpretabilityScore(3),
            statistics="centrality",
        )
        self.add_feature(
            "eccentricity_directed",
            eccentricity,
            "the ditribution of eccentricities (not counting paths of infinite length)",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        self.add_feature(
            "diameter_directed",
            diameter_directed,
            "the diameter of the graph (not counting paths of infinite length)",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "radius_directed",
            radius_directed,
            "the radius of the graph (not counting paths of infinite length)",
            InterpretabilityScore(3),
        )
コード例 #27
0
    def compute_features(self):

        # distribution of structural holes constraint
        self.add_feature(
            "constraint",
            constraint,
            "The constraint is a measure of the extent to which a node v is invested in \
            those nodes that are themselves invested in the neighbors of v",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        self.add_feature(
            "effective_size",
            effective_size,
            "The effective size of a node’s ego network is based on the concept of redundancy. \
            A person’s ego network has redundancy to the extent that her contacts are connected \
            to each other as well. ",
            InterpretabilityScore(3),
            statistics="centrality",
        )
コード例 #28
0
    def compute_features(self):
        self.add_feature(
            "largest_commsize",
            largest_commsize,
            "The ratio of the largest and second largest communities using label propagation",
            InterpretabilityScore(4),
        )

        self.add_feature(
            "ratio_commsize_maxmin",
            ratio_commsize_maxmin,
            "The ratio of the largest and second largest communities using label propagation",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "communities",
            eval_labelprop,
            "The optimal partition using label propagation algorithm",
            InterpretabilityScore(3),
            statistics="clustering",
        )
コード例 #29
0
    def compute_features(self):

        # graph clique number
        self.add_feature(
            "graph_clique_number",
            clique.graph_clique_number,
            "The clique number of a graph is the size of the largest clique in the graph",
            InterpretabilityScore(3),
        )

        # number of maximal cliques
        self.add_feature(
            "num_max_cliques",
            clique.graph_number_of_cliques,
            "The number of maximal cliques in the graph",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "num_cliques",
            n_cliques,
            "The number of cliques in the graph",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "clique_sizes",
            clique_sizes,
            "the distribution of clique sizes",
            InterpretabilityScore(3),
            statistics="centrality",
        )

        self.add_feature(
            "clique_sizes_maximal",
            maximal_clique_sizes,
            "the ratio of number of max and min size cliques",
            InterpretabilityScore(3),
        )
コード例 #30
0
    def compute_features(self):

        self.add_feature(
            "size_dominating_set",
            size_dominating_set,
            "The number of nodes in the dominating set",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "size_min_dominating_set",
            size_min_dominating_set,
            "The number of nodes in the minimum weighted dominating set",
            InterpretabilityScore(3),
        )

        self.add_feature(
            "size_min_edge_dominating_set",
            size_min_edge_dominating_set,
            "The number of nodes in the minimum edge dominating set",
            InterpretabilityScore(3),
        )