In the previous coring session, we successfully extracted the interest points from our means.
And now once we have the interest points, we need to create a graph class so that we can create a graph
to store those interest points and the respective connection.
So let's do that.
We move over the board map of class.
Right above it, we create the class that we name as graph.
So this is a graph class and the very first function that we define inside it is init function or the
initialization function.
And this one shall be used to create the instance variable for our class graph class.
The very first instance variable will be additionally to store our graph so we name it as graph and
to create additionally without actually bracket in front of it.
And then we define the two information variables instance variable that define entry point or exit point
of our group.
So that can be written as self doubt start initialize them to zero and says don't end as exit point
for graph.
And once you define the init function we move over to defining the next function that will add vertex
function.
Now this function would be used to perform the actual task of creating the graph one vertex at a time.
Along with this problem, it will also perform the connection between those vertices and their neighbors.
So let's do that.
If we define this argument itself.
The sixth next argument of Vertex.
The next argument or vertex and third argument of neighbor.
Now, if the neighbor is not provided, we initialize this to none.
And the next argument, of course.
And if the case has not been provided, we defaulted to none.
So if the neighbor is not present, this case would be for the vertex.
And if the neighbor is present in this case would be for the neighbor.
And the last argument is the cost is basically represents the cost of traversing from our vertex to
a neighbor when adding the connection.
So using this parameters, we defined this particular function, starting with the case where if the
vertex was already present graph, if it is already present, that this means that we are utilizing
this function to make a connection between the vertex and its neighbor.
So let's address that case.
So if the vertex is in self doubt graph gherkins, so if it is already present inside it, what we need
to do is to add the neighbor.
So we add that neighbor.
Several got vortex.
So we add that neighbor.
By creating additionally for that neighbor as a value of the vertex he so once we do that we a actually
record and once you create the dictionary for the neighbor, then we all we need to do is to simply
update the dictionary with a two keys that is the keys and cost for the neighbor.
So we simply write graph vertex.
Call the neighbor dictionary.
And update the key ski with key keys provided by the user in the same way update the cost.
With a cost provided by the user or the neighbour.
Now once we have done this, we address the next case or the other case where our vertex was not present.
In the case of a graph.
So we need to add that vertex to the graph.
By simply writing self your craft.
Vortex.
I'm creating additionally for that particular voters must recreate the dictionary.
We can now add the key of case.
We're adding social graph vortex, accessing that dictionary, writing history of kids and giving it
the user defined gives.
Now that we have addressed both the cases that could occur inside this function, we have completed
the process of creating the graph using AdWords and also adding the connection between the vortex and
its neighbor.
Now the last function that we need to add is simply a display graph function that we use when we want
to display our graph.
Once we have completed it.
So this takes an input argument or self.
And we simply iterate over our graph by accessing is key value fear by writing self-talk graph dot items.
This function provides us the key value iteratively over all the graph.
So now we simply print it out by writing key placeholder for that key has value.
Blissful their gainful value and then formate providing it the key and value.
So this completes the display graph function and the graph class has been completed.
So this graph graphs can now successfully be used to store the interest points and the respective connection.
So let's move on to storing the interest points and making the connection between them by creating grow
the scope.