graphs figure graph with cycle cycle models the catch- situation (which some students claim to have actually encountered at certain institutions)in which course is prerequisite for course cc is prerequisite for dand is prerequisite for graph with no cycles is called tree the binary and multiway trees we saw earlier in this book are trees in this sense howeverthe trees that arise in graphs are more general than binary and multiway treeswhich have fixed maximum number of child nodes in grapha vertex in tree can be connected to any number of other verticesprovided that no cycles are created it' easy to figure out if non-directed graph has cycles if graph with nodes has more than - edgesit must have cycles you can make this clear to yourself by trying to draw graph with nodes and edges that does not have any cycles topological sort must be carried out on directed graph with no cycles such graph is called directed acyclic graphoften abbreviated dag java code here' the java code for the topo(methodwhich carries out the topological sortpublic void topo(int orig_nverts nverts/topological sort /remember how many verts while(nverts /while vertices remain/get vertex with no successorsor - int currentvertex nosuccessors()if(currentvertex =- /must be cycle system out println("errorgraph has cycles")return