def get_ring_key(list_of_nodes):
    """
    Learn unique representations of a ring chain.
    :param list_of_nodes: a sequence of nodes that captures a ring
                          Example: [4, 1, 5, 4]
    :return a string representation of the path -> "1,4:1,5:4,5"
    """

    # Given a list of nodes V = [list_of_nodes[i-1], list_of_nodes[i]]
    # ','.join(sorted(list_of_nodes[i-1], list_of_nodes[i])) returns a
    # string of form "v1, v2" such that v1 = V_sorted[0] and v2  = V_sorted[1]

    list_of_ordered_edges = [','.join(sorted([str(list_of_nodes[i-1]), \
            str(list_of_nodes[i])])) \
            for i in range(1, len(list_of_nodes))]

    # For above input list list_of_ordered_edges = [(1,4), (1,5), (4,5)]
    # Next, sort the ordered edges and build a string of form "e1:e2:..:e_n" where
    # the e_i is encoded by the above statement.
    # ring_key for above example: "1,4:1,5:4,5"

    ring_key = ':'.join(sorted(list_of_ordered_edges))
    return ring_key