Created
September 15, 2021 01:32
-
-
Save davisvictorns/88e061d8b3246670f445f89187f10c3f to your computer and use it in GitHub Desktop.
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
edg_copy = edges.copy() | |
edge_with_weight = [] | |
while len(edg_copy) > 0: | |
curr_edge = edg_copy[0] | |
equivalent_edges = [] | |
# get the equivalent edges | |
# ('a', 'b') is equivalent to ('b', 'a') because it's not a directed connection | |
for edge in edg_copy: | |
is_different = False | |
for hashtag in edge: | |
if hashtag not in curr_edge: | |
is_different = True | |
if (not is_different): | |
equivalent_edges.append(edge) | |
weight = len(equivalent_edges) | |
edge_with_weight.append(curr_edge + (weight,)) | |
for edge in equivalent_edges: | |
edg_copy.remove(edge) | |
print(edge_with_weight) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment