Java Reference
In-Depth Information
/ ** GraphADT * /
publicinterfaceGraph{ //GraphclassADT
/ ** Initializethegraph
@paramnThenumberofvertices * /
publicvoidInit(intn);
/ ** @returnThenumberofvertices * /
publicintn();
/ ** @returnThecurrentnumberofedges * /
publicinte();
/ ** @returnv'sfirstneighbor * /
publicintfirst(intv);
/ ** @returnv'snextneighborafterw * /
publicintnext(intv,intw);
/ ** Settheweightforanedge
@parami,jThevertices
@paramwghtEdgeweight * /
publicvoidsetEdge(inti,intj,intwght);
/ ** Deleteanedge
@parami,jThevertices * /
publicvoiddelEdge(inti,intj);
/ ** Determineifanedgeisinthegraph
@parami,jThevertices
@returntrueifedgei,jhasnon-zeroweight * /
publicbooleanisEdge(inti,intj);
/ ** @returnTheweightofedgei,j,orzero
@parami,jThevertices * /
publicintweight(inti,intj);
/ ** Setthemarkvalueforavertex
@paramvThevertex
@paramvalThevaluetoset * /
publicvoidsetMark(intv,intval);
/ ** Getthemarkvalueforavertex
@paramvThevertex
@returnThevalueofthemark * /
publicintgetMark(intv);
}
Figure11.5 A graph ADT. This ADT assumes that the number of vertices is
fixed when the graph is created, but that edges can be added and removed. It also
supports a mark array to aid graph traversal algorithms.
Search WWH ::




Custom Search