# FAQ: Graphs: Python - Graph Review

This community-built FAQ covers the “Graph Review” exercise from the lesson “Graphs: Python”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## FAQs on the exercise Graph Review

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi, quick question. What"s a vertex instance?

1 Like

Vertex is a class. A vertex instance is an instance of that class, i.e., an object of type Vertex that has two attributes: value, a string, and edges, a dictionary.

You create a vertex instance by calling `my_vertex = Vertex("My Vertex")`. From that time on in your code, you can pass my_vertex just like any other object, and retreive its attributes like this:

``````this_node = my_vertex
x = this_node.value
print(x)

# Output:
My Vertex
``````
2 Likes

things that are missing in this lesson:
determining the weight of a path
example interview problem involving a graph to solve the problem
upon looking deeper in this course i believe these will be presented in the search algorithms module.

2 Likes

Hi,

I tried to make my own version of a directed graph (outside of Codecademy, so I hope this is the right place to ask the question…)

I ran into a problem where my last piece of code doesn’t output to the terminal. My Vertex class has a self.edges variable, which stores all the vertices that self connects to, in the form {to_vertex: weight, to_vertex: weight} etc.

I wanted my graph to have a self.show_edges() method, which is here:

``````def show_edges(self):
print("Edges for {self} are as follows: \n".format(self = self))
edges = {}
for vertex in self.vertices:
edges[vertex] = []
for to, weight in vertex.edges.items():
edges[vertex].append((to, weight))
return edges
``````

When I run this on the terminal, all the other methods work as expected but the .show_edges() method only prints the line “Edges for self are as follows:” and nothing else.

I know that all the code is at least being read because I tried adding print statements after each line, and they all got printed.

What’s messing with me even more is, when I run the code as a Jupyter Notebook, it works perfectly.

Is this something to do with the way the terminal works? Or is mine just broken somehow?

Many thanks,

Ash.