I am having a hard time understanding some codes. In class Graph function add_edge, there are lines

```
self.graph_dict[from_vertex.value].add_edge(to_vertex.value)
if not self.directed:
self.graph_dict[to_vertex.value].add_edge(from_vertex.value)
```

I don’t quite understand the codes, can someone help me understand? I guess the particular part that I don’t understand is “.add_edge(to_vertex.value)” part. It is a method of vertex object but why appear here? is “self.graph_dict[from_vertex.value]” an vertex object? If so, it is in a different file, how is it usable here?

```
class Graph:
def __init__(self, directed = False):
self.graph_dict = {}
self.directed = directed
def add_vertex(self, vertex):
self.graph_dict[vertex.value] = vertex
def add_edge(self, from_vertex, to_vertex):
print("Adding edge from {0} to {1}".format(from_vertex.value, to_vertex.value))
self.graph_dict[from_vertex.value].add_edge(to_vertex.value)
if not self.directed:
self.graph_dict[to_vertex.value].add_edge(from_vertex.value)
```

```
class Graph:
def __init__(self, directed = False):
self.graph_dict = {}
self.directed = directed
def add_vertex(self, vertex):
self.graph_dict[vertex.value] = vertex
def add_edge(self, from_vertex, to_vertex):
print("Adding edge from {0} to {1}".format(from_vertex.value, to_vertex.value))
self.graph_dict[from_vertex.value].add_edge(to_vertex.value)
if not self.directed:
self.graph_dict[to_vertex.value].add_edge(from_vertex.value)
```