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