Created
May 28, 2020 15:37
-
-
Save priya-dwivedi/43aad0d8c69f83c1f65879c26064a303 to your computer and use it in GitHub Desktop.
Traverse a Knowledge Graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_max_degree_node(list_of_nodes_to_eliminate, G): | |
max_degree=0 | |
all_remaining_nodes = [x for x in G.nodes() if x not in list_of_nodes_to_eliminate] | |
max_node=all_remaining_nodes[0] | |
for node in all_remaining_nodes: | |
degree = G.degree(node) | |
if degree>max_degree: | |
max_degree = degree | |
max_node = node | |
return max_degree, max_node | |
max_skill_degree, max_skill_node = get_max_degree_node(names, G) | |
print(max_skill_node) | |
print(max_skill_degree) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment