import java.io.InputStream
import java.util.Scanner
/**
* @Author WHJ
* @Date 27/12/2022 11:01
* @Version 1.0 (版本号)
* @Description:
*/
public class GraphAlgo {
public int[][] map
public int row
public int column
int[][] visited
int max
int count
public GraphAlgo(int row, int column) {
this.row = row
this.column = column
this.map=new int[row][column]
this.visited=new int[row][column]
max=0
count=0
for(int i=0
for (int j=0
visited[i][j]=0
}
}
}
void DepthFirstSearch(int x,int y){
if(map[x][y]==1||visited[x][y]==1) return
//访问这个点
this.count++
this.visited[x][y]=1
//继续深度探索
if(x+1<this.row){
DepthFirstSearch(x+1,y)
}
if(x-1>=0){
DepthFirstSearch(x-1,y)
}
if(y+1<this.column){
DepthFirstSearch(x,y+1)
}
if(y-1>=0){
DepthFirstSearch(x,y-1)
}
return
}
void showGraph(){
for (int i = 0
for (int j = 0
System.out.print(map[i][j]+" ")
}
System.out.println("//")
}
}
void findMaxConnectedsub(){
for(int i=0
for (int j = 0
if(map[i][j]==1||visited[i][j]==1){
continue
}
else{
this.count=0
DepthFirstSearch(i,j)
if(this.count>this.max){
this.max=this.count
}
}
}
}
}
public static void main(String[] args) {
Scanner is=new Scanner(System.in)
System.out.println("输入图的行")
int m=is.nextInt()
System.out.println("输入图的列")
int n=is.nextInt()
GraphAlgo graphAlgo=new GraphAlgo(m,n)
System.out.println("输入图")
for(int i=0
for (int j = 0
graphAlgo.map[i][j]=is.nextInt()
}
}
graphAlgo.findMaxConnectedsub()
System.out.println("最大推荐数:"+graphAlgo.max)
}
}