📄 algo.java
字号:
package graph;
import java.awt.*;
public class Algo{
public static ShowPanel pane;
public static void dfr(Graph g,int v,boolean[] marked){
int[] connections=g.neighbors(v);
int i;
int nextNeighbor;
marked[v]=true;
Point p=(Point)g.getLabel(v);
pane.fillPoint(p);
try{
new Thread().sleep(1000);
}catch(InterruptedException e){
}
for(i=0;i<connections.length;i++){
nextNeighbor=connections[i];
if(!marked[nextNeighbor])
dfr(g,nextNeighbor,marked);
}
}
public static void dfPrint(Graph g,int start){
boolean[] marked=new boolean[g.size()];
dfr(g,start,marked);
}
public static void wfr(Graph g,int v,boolean[] marked){
int[] connections=g.neighbors(v);
int i;
int nextNeighbor;
marked[v]=true;
Point p=(Point)g.getLabel(v);
pane.fillPoint(p);
try{
new Thread().sleep(1000);
}catch(InterruptedException e){
}
for(i=0;i<connections.length;i++){
nextNeighbor=connections[i];
if(!marked[nextNeighbor])
dfr(g,nextNeighbor,marked);
}
}
public static void wfPrint(Graph g,int start){
boolean[] marked=new boolean[g.size()];
wfr(g,start,marked);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -