def get_ground_truth(G=None): """ Returns a VertexClustering object of the ground truth of the graph G. The ground truth for this football data is the conference to which each team belongs. """ if G is None: G = get_graph() if G is None: print("Unable to get graph") sys.exit(0) #by default conferences are identified by a float number float_membership = G.vs['value'] conf_map = {} for vertex_id, conference_id in enumerate(G.vs['value']): if conference_id not in conf_map: conf_map[conference_id] = [] conf_map[conference_id].append(vertex_id) cluster_list = [v for k, v in conf_map.items()] return VertexCover(G, cluster_list)
def get_ground_truth(self, G): cluster_list = [[], [], []] for vertex_id, party in enumerate(G.vs['party']): cluster_list[self.__party_to_cluster__(party)].append(vertex_id) return VertexCover(G, cluster_list)
def get_ground_truth(self, G): """ returns a VertexClustering object of the ground truth of the graph G. """ clusters_list = [[ 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 16, 17, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 ], [8, 9, 14, 15, 18, 21]] return VertexCover(G, clusters_list)
def cover_from_membership(membership, G): if (membership is None): return None cluster_dict = {} for vertex_id, cluster_id_list in enumerate(membership): for cluster_id in cluster_id_list: if (cluster_id not in cluster_dict): cluster_dict[cluster_id] = [] cluster_dict[cluster_id].append(vertex_id) return VertexCover(G, [v for v in cluster_dict.values()])
def get_ground_truth(self, G): """ This Ground Truth is the country of the airport """ if G is None: return cluster_dict = defaultdict(list) for airport_id, airport_location in enumerate(G.vs['country']): cluster_dict[airport_location].append(airport_id) return VertexCover(G, [v for v in cluster_dict.values()])
def get_ground_truth(self, G): """ Returns a VertexClustering object of the ground truth of the graph G. The ground truth for this football data is the conference to which each team belongs. """ #by default conferences are identified by a float number float_membership = G.vs['value'] conf_map = {} for vertex_id, conference_id in enumerate(float_membership): if conference_id not in conf_map: conf_map[conference_id] = [] conf_map[conference_id].append(vertex_id) cluster_list = [v for k, v in conf_map.items()] return VertexCover(G, cluster_list)
def get_ground_truth(self, G): class_list = G.vs['classname'] class_dict = dict.fromkeys(class_list) #set the indices for lookup purposes. These will be the cluster ids for idx, k in enumerate(class_dict): class_dict[k] = [] for student_number, class_id in enumerate(class_list): class_dict[class_id].append(student_number) cluster_list = [] for cluster in class_dict.values(): cluster_list.append(cluster) return VertexCover(G, cluster_list)
def get_ground_truth(self, G): #ground truth table divisions = { "boston-celtics":0, "brooklyn-nets":0, "new-york-knicks":0, "philadelphia-76ers":0, "toronto-raptors":0, "chicago-bulls":1, "cleveland-cavaliers":1, "detroit-pistons":1, "indiana-pacers":1, "milwaukee-bucks":1, "atlanta-hawks":2, "charlotte-bobcats":2, "miami-heat":2, "orlando-magic":2, "washington-wizards":2, "dallas-mavericks":3, "houston-rockets":3, "memphis-grizzlies":3, "new-orleans-pelicans":3, "san-antonio-spurs":3, "denver-nuggets":4, "minnesota-timberwolves":4, "oklahoma-city-thunder":4, "portland-trail-blazers":4, "utah-jazz":4, "golden-state-warriors":5, "los-angeles-clippers":5, "los-angeles-lakers":5, "phoenix-suns":5, "sacramento-kings":5 } cluster_list = [[],[],[],[],[],[]] for vertex_id, team_name in enumerate(G.vs['name']): cluster_list[divisions[team_name]].append(vertex_id) return VertexCover(G, cluster_list)
def get_ground_truth(self, G): """ Get a Vertex Cover representing the ground truth for this graph. It's not apparent what the right "ground truth" is but a guess is "country". It might be true that "source" (which is the registrar that handled the transaction ) is a better guess """ if G is None: return GROUND_TRUTH_FIELD = 'country' membership = G.vs[GROUND_TRUTH_FIELD] # Map community names to integers community_name_to_id = {} max_community_seen = 0 cluster_dict = defaultdict(list) for vertex_id, community_name in enumerate(membership): cluster_dict[community_name].append(vertex_id) cluster_list = [v for v in cluster_dict.values()] return VertexCover(G, cluster_list)