소스 대상 노드와 임계 값을 포함하는 큰 텍스트 파일 (20GB) 파일이 있습니다. 임계 값> 0이면 그렇지 않은 경우 연결됩니다. 배열 또는 배열 목록에 연결된 노드를 추가하고 싶습니다. (하나는 많은 양의 데이터에 적합합니까?) 그리고 거대한 연결 구성 요소를 찾는 것입니다. BFS 알고리즘은 최단 경로에 대한 해결책이라고 생각합니다.네트워크에서 가장 큰 연결된 구성 요소
TXT 파일
100 101 -0.3434
100 102 1.0023
100 103 1.100
103 104 0.210
...
내 코드 : 당신이 올바르게 구현하지 않는 BTW 당신이 적용 나중에 그래프 데이터 구조를 고려 할 수있는 경우
String line = null;
HashMap<Integer,ArrayList<Node>> arr = new HashMap<Integer,ArrayList<Node>>();
BufferedReader reader = new BufferedReader(new FileReader("C:/Users/UserPC/Desktop/output.txt"));
while((line = reader.readLine()) != null){
String[] spl = line.split("\\s+");
//System.out.println(spl[0]+","+spl[1]);
int source = Integer.parseInt(spl[0]);
int target = Integer.parseInt(spl[1]);
arr.computeIfAbsent(source, k -> new ArrayList<>()).add(new Node(target));
}
reader.close();
이 코드는 "내 코드 완성"요청과 유사합니다.이 요청은 StackOverflow에서 오프 토픽입니다. –
아니요. 나는 단지 어떻게 할 것인가에 대해 더 많은 의견을 갖고 싶었습니다. –
투표를 제거하기 위해 질문을 어떻게 개선 할 수 있습니까? –