public Graph(String filename) throws Exception{
    //construct an initial graph with maximum locations
    locations = new Location[maximum];
    for (int i=0; i < maximum; i++) {
      locations[i]=new Location(null);
    }
    adjacent = new boolean[maximum][maximum];
    weight = new double[maximum][maximum]; 
    //get all the information
    FileInputStream in;
    String s="";
    int innum;
    char c;
    try{
      in=new FileInputStream(filename);
      while((innum=in.read())!=-1){
        c=(char)innum;
        if(c=='\n'){
          //parse s now
          if(!s.equals("")){
            if(s.charAt(1)=='m'){
              String imgname="";
              String scale="";
              int j;
              for(j=17;s.charAt(j)!='\"';j++){
                imgname=imgname+s.charAt(j);
              }
              for(j=j+1;s.charAt(j)!='\"';j++);
              imageName=imgname;
              for(j=j+1;s.charAt(j)!='\"';j++){
                scale=scale+s.charAt(j);
              }
              scaleFeetPixel=Double.parseDouble(scale);
            }else if(s.charAt(1)=='l'){
              String id="";
              String name="";
              String x="";
              String y="";
              int j;
              for(j=14;s.charAt(j)!='\"';j++){
                id=id+s.charAt(j);
              }
              for(j=j+1;s.charAt(j)!='\"';j++);
              for(j=j+1;s.charAt(j)!='\"';j++){
                name=name+s.charAt(j);
              }
              for(j=j+1;s.charAt(j)!='\"';j++);
              for(j=j+1;s.charAt(j)!='\"';j++){
                x=x+s.charAt(j);
              }
              for(j=j+1;s.charAt(j)!='\"';j++);
              for(j=j+1;s.charAt(j)!='\"';j++){
                y=y+s.charAt(j);
              }
              Point newpt=new Point(Integer.parseInt(x),Integer.parseInt(y));
              int index=addLoc(newpt);
              locations[index].setID(Integer.parseInt(id));
              locations[index].setName(name);
            }else if(s.charAt(1)=='p'){
              String idfrom="";
              String idto="";
              int j;
              for(j=14;s.charAt(j)!='\"';j++){
                idfrom=idfrom+s.charAt(j);
              }
              for(j=j+1;s.charAt(j)!='\"';j++);
              for(j=j+1;s.charAt(j)!='\"';j++){
                idto=idto+s.charAt(j);
              }
              int IDfrom=findIndex(Integer.parseInt(idfrom));
              int IDto=findIndex(Integer.parseInt(idto));
              setEdge(IDfrom,IDto);
            }
            //reset s
            s="";
          }
        }else{
          s=s+c;
        }
      }
      if(in!=null){
        in.close();
      }
    }catch(Exception e){
      System.out.println("Error:"+e.getMessage());
      throw new Exception();
    }
  }