[Python] Create linked list in python

2022-6-22 写技术

class Node:
    def __init__(self, dst = -1, cost = -1):
        self.dst = dst
        self.cost = cost
        self.link = None


def image_to_graph(image):
    print("ssss\n")
    header = Node()
    header.link = Node(1,1)
    header.link.link = Node(2,2)

    p = header

    while( p != None):
        print(" :", p.dst, p.cost, "\n")
        p = p.link

    print(" end\n")

image_to_graph(None)

标签: python Data Structures data_structures

发表评论:

Powered by anycle 湘ICP备15001973号-1