Created
August 10, 2020 17:39
-
-
Save simonespa/aed3a5ea7e58b8f955ac229603632dbb to your computer and use it in GitHub Desktop.
Kruskal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 7 | |
| pc001 pc002 57 | |
| pc001 pc003 12 | |
| pc002 pc003 2 | |
| pc002 pc004 24 | |
| pc003 pc005 6 | |
| pc005 pc004 31 | |
| pc002 pc006 45 | |
| 5 | |
| pc001 pc002 3 | |
| pc002 pc003 4 | |
| pc004 pc005 10 | |
| pc005 pc006 13 | |
| pc006 pc001 20 | |
| 7 | |
| pc001 pc002 7 | |
| pc002 pc003 8 | |
| pc002 pc004 2 | |
| pc001 pc003 9 | |
| pc003 pc004 18 | |
| pc004 pc005 20 | |
| pc004 pc006 22 | |
| 7 | |
| pc001 pc002 13 | |
| pc001 pc003 15 | |
| pc003 pc004 5 | |
| pc003 pc005 8 | |
| pc002 pc003 28 | |
| pc004 pc005 11 | |
| pc005 pc006 22 | |
| 7 | |
| pc001 pc002 11 | |
| pc003 pc004 1 | |
| pc003 pc001 7 | |
| pc005 pc006 18 | |
| pc005 pc003 2 | |
| pc006 pc007 14 | |
| pc001 pc007 30 | |
| 9 | |
| pc001 pc002 4 | |
| pc001 pc003 1 | |
| pc001 pc004 3 | |
| pc002 pc003 4 | |
| pc002 pc004 4 | |
| pc003 pc004 2 | |
| pc003 pc006 4 | |
| pc004 pc006 6 | |
| pc005 pc006 5 | |
| 4 | |
| pc001 pc002 4 | |
| pc001 pc003 3 | |
| pc004 pc005 6 | |
| pc005 pc006 6 | |
| 4 | |
| pippo pluto 3 | |
| pippo minni 1 | |
| pluto minni 5 | |
| topol ziopa 2 | |
| 5 | |
| pippo pluto 3 | |
| pluto pippo 4 | |
| pippo minni 4 | |
| pluto minni 3 | |
| topol ziopa 5 | |
| 4 | |
| pippo pluto 3 | |
| pluto pippo 4 | |
| minni pluto 2 | |
| topol ziopa 5 | |
| 6 | |
| pc001 pc002 1 | |
| pc001 pc004 3 | |
| pc002 pc003 3 | |
| pc004 pc003 4 | |
| pc001 pc003 5 | |
| pc002 pc004 2 | |
| 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package prova; | |
| import java.io.BufferedReader; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.IOException; | |
| import java.io.InputStreamReader; | |
| import java.util.HashMap; | |
| import java.util.HashSet; | |
| import java.util.Map; | |
| import java.util.Set; | |
| public class Main { | |
| public static void main(String[] args) throws IOException { | |
| BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"))); | |
| Map<String, Integer> map = new HashMap<>(); | |
| Set<String> set = new HashSet<>(); | |
| String number = in.readLine(); | |
| int n = Integer.parseInt(number); | |
| for (int i = 0; i < n; i++) { | |
| String line = in.readLine(); | |
| String[] split = line.split(" "); | |
| set.add(split[0]); | |
| set.add(split[1]); | |
| } | |
| in.close(); | |
| System.out.println("I nodi del grafo sono " + set.size() + " e sono:"); | |
| for (String s : set) { | |
| System.out.println(s); | |
| } | |
| /* | |
| map.put("pc001", 0); | |
| Set<String> set = map.keySet(); | |
| System.out.println(map.size()); | |
| for (String s : set) { | |
| System.out.println("Key = " + s); | |
| System.out.println("Value = " + map.get(s)); | |
| } | |
| */ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment