educative.io

Educative

Add_edge function is not clear

def add_edge(self, source, destination):
        """
        add edge
        :param source: Source Vertex
        :param destination: Destination Vertex
        """

        # Adding the node to the source node
        node = AdjNode(destination)
        
        node.next = self.graph[source]
        self.graph[source] = node

The above function is not very clear to me. Could you please explain what is going on here? Why is node.next being pointed to self.graph[source]?

Hello @Vishal_Ahuja1!
Can you please provide the link to the lesson?
Thank you for reaching out to us. We hope Educative has inspired you to further your learning. :slight_smile: