If you had graph data (you have an image) how do you write it in a program? I mean how do you represent it in a program? What structure would you use to write the graph? I mean how do you code it in a program for the computer to read the graph? A computer can’t read a drawing, so how do you code the program to read the graph? What structure would you use in a computer so the computer can read the graph? Explain in your own words.
first of all if you have a image than you will have to go for OCR which is concept of machine learning you will give a image as an input than computer will read a image and it will automatically identify the graph and will represent the graph using the programe.
here for storeing the graph we will use pointers and class to represent the graph. you will have to enter the garph node value with edge as input.
i will make a class called garph it will have two member noofvertices and one list to store the graph.
here i can use the adjancy matrix or adjantancy list to store the graph
adjantancy matrix:
here for ith row and jth coloum if the value of that cell is 1 than it wiil have the edge between the ith row to jth column.
like wise 2.Adjacency List:
here 1--->2---->4---->3 there is a edge in between that node. in a doubly linked list the weight will be also stored.
we can do it usig like one of these method.
in that class which we have named a graph i will add a function named add_edge(u,v)
this function will store my edge between u and v. i will store it in a list of our member.
that function is main.
and the last function is to print the garph in whatever manner you like to print.
before creating a class Graph i will create a one more class node which will have only two data member node_data and one pointer to store the information and to point the other node.
if you have till query than let me know.
Get Answers For Free
Most questions answered within 1 hours.