The networkx library contains probably all you need to solve the question
Given a skill A, is skill B a related skill?
We'll assume that related skills are directional (knowing Python might
lead to knowing AWS, but not vice versa). For this, we'll use the
directed graph model.
We can also use shortest path length to model relatedness level and
use that to color and layer the output graph.
In the program below, unrelated skills are removed to simplify the
graph: Prolog is not related to Python (arrows are wrong direction),
C and Embedded systems are not connected to the Python skill graph.
import itertools
import matplotlib.pyplot as plt
import networkx as nx
def skill_rel(skill, rel_skill):
if skill not in G:
print(f"{skill} skill no longer in graph")
return
if rel_skill not in G:
print(f"{rel_skill} skill no longer in graph")
return
related = nx.has_path(G, skill, rel_skill)
print(f"{skill} skill and relation to {rel_skill}",
related, end=' ')
if related:
print('level',
nx.shortest_path_length(G, skill, rel_skill))
def level_rel(skill, rel_skill):
related = nx.has_path(G, skill, rel_skill)
if related:
return nx.shortest_path_length(G, skill, rel_skill)
else:
return 999
pairs = [('Python', 'AWS'),
('Python', 'Machine Learning'),
('Python', 'Big Data'),
('AWS', 'Hadoop'),
('C', 'Embedded Systems'),
('Prolog', 'Artificial Intelligence'),
('Machine Learning', 'Deep Learning'),
('Machine Learning', 'Artificial Intelligence')]
skill = 'Python'
G = nx.DiGraph()
G.add_edges_from(pairs)
# Remove unrelated skills (>= level 5)
unrelatedness = 5
unrelated = [node for node in G if level_rel(skill, node) >= unrelatedness]
G.remove_nodes_from(unrelated)
# Group/color nodes based on relatedness to use shell graph drawing
nlevel = [(node, level_rel(skill, node)) for node in G]
g1 = itertools.groupby(sorted(nlevel, key=lambda x: x[1]), key=lambda x: x[1])
shells = tuple(tuple(x[0] for x in g) for _,g in g1)
pos = nx.shell_layout(G, nlist=shells)
colors = [lvl[1] for lvl in nlevel]
nx.draw_networkx(G, pos, node_color=colors, with_labels=True)
plt.show()
skill_rel(skill, 'Hadoop')
skill_rel('Prolog', 'Hadoop')
print('Level 2 related skills from', skill, shells[2])
Output graph with levels colored:

Output:
# Python skill and relation to Hadoop True level 2
# Prolog skill no longer in graph
# Level 2 related skills from Python
# ('Hadoop', 'Artificial Intelligence', 'Deep Learning')