- packageom.eshore.sweetop.minpath;
- publicclassBellmanFordextendsGraphics{
- publicBellmanFord(Vertex...vs){
- for(Vertexv:vs){
- list.add(v);
- }
- }
- @Override
- publicbooleanminPath(Vertexv){
- initSingleSource(v);
- for(inti=0;i<list.size()-1;i++){
- for(Vertexu:list){
- for(Vertexw:u.getV()){
- this.relax(u,w);
- }
- }
- }
- for(Vertexu:list){
- for(Vertexw:u.getV()){
- if(w.getD()>u.getD()+u.weight(w)){
- returnfalse;
- }
- }
- }
- returntrue;
- }
- }