next up previous contents
Next: The New Path Printing Up: Dynamic Programming Using Typeless Previous: Run-Time Results:

Adding Graphics Capability to the DP Objects:

We want to be able to draw optimal paths from start to goal nodes and so forth, so we need to talk about how we will implement these methods. We will update the functions void BackwardPathPrint(Gnode *start,Gnode *goal) and ForwardPathPrint(Gnode *start,Gnode *goal) to the new prototypes GedgePtrBag& BackwardPathPrint(Gnode *start,Gnode *goal,Pixel *DPColor) and GedgePtrBag& ForwardPathPrint(Gnode *start,Gnode *goal,Pixel *DPColor) so that we can send in color information (Pixel *DPColor) to set the color of the start and goal nodes and set the color of the optimal path between them. In addition, we will store the path between the start and goal node in a GedgePtrBag object, a bag of edge pointers, for easy access. Then we can simply ship this bag of edges to a drawing method to paint the path on the screen.

We will use a new Graph drawing method to do this called Graph& drawpath(Drawable D,GedgePtrBag& Path) which, of course, requires us to alter the original graph class. However, this seems reasonable as it was an oversight to fail to include the ability to draw an arbitrary path of edges to begin with.



 
next up previous contents
Next: The New Path Printing Up: Dynamic Programming Using Typeless Previous: Run-Time Results:
Jim Peterson
1999-04-13