system out print("minimum spanning tree")thegraph mst()/minimum spanning tree system out println()/end main(/end class mstapp ///////////////////////////////////////////////////////////////topological sorting with directed graphs topological sorting is another operation that can be modeled with graphs it' useful in situations in which items or events must be arranged in specific order let' look at an example an examplecourse prerequisites in high school and collegestudents find (sometimes to their dismaythat they can' take just any course they want some courses have prerequisites--other courses that must be taken first indeedtaking certain courses may be prerequisite to obtaining degree in certain field figure shows somewhat fanciful arrangement of courses necessary for graduating with degree in mathematics figure course prerequisites to obtain your degreeyou must complete the senior seminar and (because of pressure from the english departmentcomparative literature but you can' take senior seminar without having already taken advanced algebra and analytic geometryand you can' take comparative literature without taking english composition alsoyou need geometry for analytic geometryand algebra for both advanced algebra and analytic geometry directed graphs as the figure showsa graph can represent this sort of arrangement howeverthe graph needs feature we haven' seen beforethe edges need to have direction figure small directed graph when this is the casethe graph is called directed graph in directed graph you can only proceed one way along an edge the arrows in figure show the direction of