0
public class Arc 
{
   String startPoint;
   String endPoint;
   int distance;

   Arc(String startPoint,String endPoint,int distance)
   {
       this.startPoint=startPoint;
       this.endPoint=endPoint;
       this.distance=distance;
   }
   public String getStartPoint()
   {
    return startPoint;   
   }
   public String getEndPoint()
   {
       return endPoint;
   }
   public int getDistance()
   {
       return distance;
   }
}


public class ArcCollections 
{           
    private HashMap<String, HashMap<String, Integer>> outMap = new  HashMap<String,HashMap<String,Integer>>();
private HashMap<String, Integer> inMap = new HashMap<String,Integer>();

    public void addArc(Arc arc)
    {
        String st = arc.getStartPoint();
    String end = arc.getEndPoint();
    int dist = arc.getDistance();

    inMap.put(end, dist);
    outMap.put(st,inMap);
    }       
}

示例输入类似于:(即){source,{destination,distance}}

如何在指定的地图结构中插入这些值?因为在调试时inMap产量只有null

这些值是从 excel 中读取并通过 main 函数中的对象传递的,如下所示:

tmpArc = new Arc(tempFromCity,tempToCity,dist);
4

0 回答 0