如何在LinkedHashMap中为key赋予多个值

时间:2016-09-26 23:06:30

标签: java graph

我有一个图表,我想给每个节点赋予不同的值,因为我想计算每个节点的中介,前任等等, 但我认为如果我使用地图,前一个值将被替换。我怎么能弄明白呢?以下是我的代码。我尝试使用地图

  LinkedHashMap<Vertex<E>, Double> Betweenness = new LinkedHashMap<>();

  for(Vertex<E> vertex : graph.vertexSet())
  {
      Betweenness.put(vertex,0.0);            
  }

  for(Vertex<E> vertex : graph.vertexSet())
  {
      //Create stack to keep track of vertices in order to calculate value of flow
      StackADT<Vertex<E>> processingStack = new LinkedStack<Vertex<E>>();

      LinkedHashMap<Vertex<E> ,List<Vertex<E>>> Predecessor = new LinkedHashMap<>();

      for(Vertex<E> predecessorofVertex : graph.vertexSet())
      {
          List<Vertex<E>> PredecessorList = new LinkedList<>();
          Predecessor.put(predecessorofVertex, PredecessorList);
      } 
  }

0 个答案:

没有答案