+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
6bd33a4
master
1package dist ; 2import java .io .*; 3import java .util .*; 4public class Topology { 5// returns true if read neighbors successfully 6public static boolean readNeighbors (int myId , 7List <Integer >neighbors ) { 8System .out .println ("Reading topology" ); 9try { 10Scanner sc =new Scanner (new FileReader ("topology" +myId )); 11while (sc .hasNext ()) { 12int neighbor =sc .nextInt (); 13neighbors .add (neighbor ); 14 } 15 }catch (FileNotFoundException e ) { 16return false ; 17 } 18System .out .println (neighbors .toString ()); 19return true ; 20 } 21public static void setComplete (int myId , 22List <Integer >neighbors ,int numProc ) { 23for (int i =0 ;i <numProc ; ++i ) { 24if (i !=myId )neighbors .add (i ); 25 } 26 } 27public static void main (String []args ) { 28LinkedList <Integer >l =new LinkedList <Integer >(); 29Topology .readNeighbors (Integer .parseInt (args [0 ]),l ); 30 } 31}