View Single Post
Old Apr 15th, 2006, 4:47 PM   #6
cwl157
Professional Programmer
 
Join Date: Feb 2005
Posts: 345
Rep Power: 4 cwl157 is on a distinguished road
ok i think i might be on to something. So each vertex can be represented with a number and there is a maximum of 50 vertices. Therefore, i have a method that takes the number of vertices the user wants and makes an array of numbers each one representing a vertex. So then when the user enters the edges they would say a number and then i would take that number from the array. I think this will work. However, i have one question. After they enter the starting vertex for the edge how do i take that number out of the array and i think i am going to have to make it a node linked to the number the user picks as the ending vertex with the cost of the edge in there too. I have a vertex class that just has the method that fills the array with the number the user enteres for the number of vertices. I think i am going to have an edge class. Since i am just using numbers could the start and end just be int and the weight be an int and then just have the constructor set the start and end based on what the user enters? I am confused because something tells me a graph is like a tree but with more than 2 children. I have a feeling that at some point the vertices will have to be nodes linked together like a tree and i will have to recursively go through the graph. I am not sure how to make this though.
cwl157 is offline   Reply With Quote