Skip to content

Instantly share code, notes, and snippets.

@priya-dwivedi
Created May 28, 2020 15:37
Show Gist options
  • Save priya-dwivedi/43aad0d8c69f83c1f65879c26064a303 to your computer and use it in GitHub Desktop.
Save priya-dwivedi/43aad0d8c69f83c1f65879c26064a303 to your computer and use it in GitHub Desktop.
Traverse a Knowledge Graph
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