# 第三次总结性作业

## 第一次作业

### 一、基于UML和度量的架构分析

Method CogC ev(G) iv(G) v(G)
Main.main(String[]) 0 1 1 1
MyEqualPersonIdException.MyEqualPersonIdException(int) 2 1 2 2
MyEqualPersonIdException.print() 0 1 1 1
MyEqualRelationException.MyEqualRelationException(int,int) 8 1 4 5
MyEqualRelationException.print() 0 1 1 1
MyNetwork.MyNetwork() 0 1 1 1
MyNetwork.compareName(int,int) 2 3 2 3
MyNetwork.contains(int) 0 1 1 1
MyNetwork.getPerson(int) 2 2 2 2
MyNetwork.insert(Person) 1 1 2 2
MyNetwork.isCircle(int,int) 2 3 2 3
MyNetwork.queryBlockSum() 0 1 1 1
MyNetwork.queryNameRank(int) 2 2 2 3
MyNetwork.queryPeopleSum() 0 1 1 1
MyNetwork.queryValue(int,int) 3 4 3 4
MyPerson.MyPerson(int,String,int) 0 1 1 1
MyPerson.compareTo(Person) 0 1 1 1
MyPerson.equals(Object) 3 2 2 3
MyPerson.getAge() 0 1 1 1
MyPerson.getId() 0 1 1 1
MyPerson.getName() 0 1 1 1
MyPerson.queryValue(Person) 1 2 1 2
MyPersonIdNotFoundException.MyPersonIdNotFoundException(int) 2 1 2 2
MyPersonIdNotFoundException.print() 0 1 1 1
MyRelationNotFoundException.MyRelationNotFoundException(int,int) 8 1 4 5
MyRelationNotFoundException.print() 0 1 1 1
Trie.Trie() 0 1 1 1
Trie.createSon(int) 1 1 2 2
Trie.getEnd() 0 1 1 1
Trie.getSon(int) 0 1 1 1
Trie.getSum() 0 1 1 1
Trie.getSum(int) 3 3 2 3
UnionFindSet.UnionFindSet() 0 1 1 1
UnionFindSet.getFather(int) 6 5 3 5
UnionFindSet.getUnionNum() 0 1 1 1
UnionFindSet.inUnion(int,int) 0 1 1 1
UnionFindSet.insert(int) 0 1 1 1
Class OCavg OCmax WMC
Main 1 1 1
MyEqualPersonIdException 1.5 2 3
MyEqualRelationException 3 5 6
MyNetwork 2.25 4 27
MyPerson 1.22 2 11
MyPersonIdNotFoundException 1.5 2 3
MyRelationNotFoundException 3 5 6
Trie 1.38 3 11
UnionFindSet 1.83 5 11

### 二、实现规格所采取的设计策略

#### （一）容器的选择和使用

public class MyNetwork implements Network {
private HashMap<Integer, Person> people;
private Trie root;
private UnionFindSet ufs;
}

public class MyPerson implements Person {
private int id;
private String name;
private int age;
private HashMap<Integer, Person> acquaintance;
private HashMap<Integer, Integer> value;
}

public class UnionFindSet {
private int unionNum;
private HashMap<Integer, Integer> parent;
}

public class Trie {
private TreeMap<Integer, Trie> son;
private int sum;
private int end;
}


#### （二）性能问题分析

##### 1、isCircle

isCircle 操作有着极好的性质，那就是点和点之间关联的边是不会被删除的（虽然这和我们印象中的人际关系有所不符），因此对于这种操作我们可以采取并查集来维护。

public void insert(int id) {
parent.put(id, id);
++unionNum;
}


private int getFather(int id) {
int root = id;
while (true) {
int father = parent.get(root);
if (father == root) { break; }
root = father;
}
int now = id;
while (true) {
int father = parent.get(now);
if (father == now) { break; }
parent.put(now, root); //路径压缩
now = father;
}
return root;
}

public boolean inUnion(int id1, int id2) {
int f1 = getFather(id1);
int f2 = getFather(id2);
return f1 == f2;
}


public void link(int id1, int id2) {
int f1 = getFather(id1);
int f2 = getFather(id2);
if (f1 == f2) { return; }
--unionNum;
parent.put(f1, f2);
}


##### 2、queryNameRank

private void insert(Person person) {
Trie now = root;
String name = person.getName();
int len = name.length();
for (int i = 0; i < len; ++i) {
int t = name.charAt(i);
now = now.createSon(t);
}
}

public Trie getSon(int i) {
return son.get(i);
}

public Trie createSon(int i) {
if (!son.containsKey(i)) {
son.put(i, new Trie());
}
return son.get(i);
}

public void add() {
++sum;
}

++end;
}

private int getEnd() {
return end;
}

private int getSum() {
return sum;
}


Trie 树的建立就和一般的字典树一样，我们统计了每个点子树中有多少字符串，同时统计了每个点结束的字符串个数。]

public int getSum(int asc) {
int sum = getEnd();
Iterator<Map.Entry<Integer, Trie>> entries = son.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<Integer, Trie> entry = entries.next();
int key = entry.getKey();
if (key >= asc) { break; }
Trie now = entry.getValue();
sum += now.getSum();
}
return sum;
}


public int queryNameRank(int id) throws PersonIdNotFoundException {
if (!people.containsKey(id)) {
throw new MyPersonIdNotFoundException(id);
}
Trie now = root;
String name = people.get(id).getName();
int len = name.length();
int rank = 0;
for (int i = 0; i < len; ++i) {
int t = name.charAt(i);
rank += now.getSum(t);
now = now.getSon(t);
}
return rank + 1;
}


public void addMessage(Message message) {
}


## 第二次作业

### 一、基于UML和度量的架构分析

Method CogC ev(G) iv(G) v(G)
Main.main(String[]) 0 1 1 1
MyEqualGroupIdException.MyEqualGroupIdException(int) 2 1 2 2
MyEqualGroupIdException.print() 0 1 1 1
MyEqualMessageIdException.MyEqualMessageIdException(int) 2 1 2 2
MyEqualMessageIdException.print() 0 1 1 1
MyEqualPersonIdException.MyEqualPersonIdException(int) 2 1 2 2
MyEqualPersonIdException.print() 0 1 1 1
MyEqualRelationException.MyEqualRelationException(int,int) 8 1 4 5
MyEqualRelationException.print() 0 1 1 1
MyGroup.MyGroup(int) 0 1 1 1
MyGroup.delPerson(Person) 1 1 2 2
MyGroup.equals(Object) 3 2 2 3
MyGroup.getAgeMean() 1 2 1 2
MyGroup.getAgeVar() 1 2 1 2
MyGroup.getId() 0 1 1 1
MyGroup.getSize() 0 1 1 1
MyGroup.getValueSum() 0 1 1 1
MyGroup.hasPerson(Person) 0 1 1 1
MyGroupIdNotFoundException.MyGroupIdNotFoundException(int) 2 1 2 2
MyGroupIdNotFoundException.print() 0 1 1 1
MyMessage.MyMessage(int,int,Person,Group) 0 1 1 1
MyMessage.MyMessage(int,int,Person,Person) 0 1 1 1
MyMessage.equals(Object) 3 2 2 3
MyMessage.getGroup() 0 1 1 1
MyMessage.getId() 0 1 1 1
MyMessage.getPerson1() 0 1 1 1
MyMessage.getPerson2() 0 1 1 1
MyMessage.getSocialValue() 0 1 1 1
MyMessage.getType() 0 1 1 1
MyMessageIdNotFoundException.MyMessageIdNotFoundException(int) 2 1 2 2
MyMessageIdNotFoundException.print() 0 1 1 1
MyNetwork.MyNetwork() 0 1 1 1
MyNetwork.compareName(int,int) 2 3 2 3
MyNetwork.contains(int) 0 1 1 1
MyNetwork.containsMessage(int) 0 1 1 1
MyNetwork.delFromGroup(int,int) 5 4 3 4
MyNetwork.getGroup(int) 2 2 2 2
MyNetwork.getMessage(int) 2 2 2 2
MyNetwork.getPerson(int) 2 2 2 2
MyNetwork.insert(Person) 1 1 2 2
MyNetwork.isCircle(int,int) 2 3 2 3
MyNetwork.queryBlockSum() 0 1 1 1
MyNetwork.queryGroupAgeMean(int) 2 2 2 2
MyNetwork.queryGroupAgeVar(int) 2 2 2 2
MyNetwork.queryGroupPeopleSum(int) 2 2 2 2
MyNetwork.queryGroupSum() 0 1 1 1
MyNetwork.queryGroupValueSum(int) 2 2 2 2
MyNetwork.queryNameRank(int) 2 2 2 3
MyNetwork.queryPeopleSum() 0 1 1 1
MyNetwork.querySocialValue(int) 2 2 2 2
MyNetwork.queryValue(int,int) 3 4 3 4
MyNetwork.sendMessage(int) 13 4 9 9
MyPerson.MyPerson(int,String,int) 0 1 1 1
MyPerson.compareTo(Person) 0 1 1 1
MyPerson.delGroup(Group) 0 1 1 1
MyPerson.equals(Object) 3 2 2 3
MyPerson.getAge() 0 1 1 1
MyPerson.getId() 0 1 1 1
MyPerson.getMessages() 0 1 1 1
MyPerson.getName() 0 1 1 1
MyPerson.getSocialValue() 0 1 1 1
MyPerson.queryValue(Person) 1 2 1 2
MyPersonIdNotFoundException.MyPersonIdNotFoundException(int) 2 1 2 2
MyPersonIdNotFoundException.print() 0 1 1 1
MyRelationNotFoundException.MyRelationNotFoundException(int,int) 8 1 4 5
MyRelationNotFoundException.print() 0 1 1 1
Trie.Trie() 0 1 1 1
Trie.createSon(int) 1 1 2 2
Trie.getEnd() 0 1 1 1
Trie.getSon(int) 0 1 1 1
Trie.getSum() 0 1 1 1
Trie.getSum(int) 3 3 2 3
UnionFindSet.UnionFindSet() 0 1 1 1
UnionFindSet.getFather(int) 6 5 3 5
UnionFindSet.getUnionNum() 0 1 1 1
UnionFindSet.inUnion(int,int) 0 1 1 1
UnionFindSet.insert(int) 0 1 1 1
Class OCavg OCmax WMC
Main 1 1 1
MyEqualGroupIdException 1.5 2 3
MyEqualMessageIdException 1.5 2 3
MyEqualPersonIdException 1.5 2 3
MyEqualRelationException 3 5 6
MyGroup 1.5 2 18
MyGroupIdNotFoundException 1.5 2 3
MyMessage 1.11 2 10
MyMessageIdNotFoundException 1.5 2 3
MyNetwork 2.41 6 65
MyPerson 1.35 3 23
MyPersonIdNotFoundException 1.5 2 3
MyRelationNotFoundException 3 5 6
Trie 1.38 3 11
UnionFindSet 1.83 5 11

### 二、实现规格所采取的设计策略

#### （一）容器的选择和使用

public class MyNetwork implements Network {
private HashMap<Integer, Person> people;
private HashMap<Integer, Group> groups;
private HashMap<Integer, Message> messages;
private Trie root;
private UnionFindSet ufs;
}

public class MyGroup implements Group {
private int id;
private HashMap<Integer, Person> people;
private int ageSum;
private int ageQSum;
private int valueSum;
}

public class MyPerson implements Person {
private int id;
private String name;
private int age;
private HashMap<Integer, Person> acquaintance;
private HashMap<Integer, Integer> value;
private int socialValue;
private HashMap<Integer, Group> groups;
}

public class MyMessage implements Message {
private int id;
private int socialValue;
private int type;
private Person person1;
private Person person2;
private Group group;
}


#### （二）性能问题分析

public void addPerson(Person person) {
people.put(person.getId(), person);
ageSum += person.getAge();
ageQSum += person.getAge() * person.getAge();
for (Integer id : people.keySet()) {
Person peo = people.get(id);
valueSum += peo.queryValue(person);
}
}

public void delPerson(Person person) {
ageSum -= person.getAge();
ageQSum -= person.getAge() * person.getAge();
people.remove(person.getId());
for (Integer id : people.keySet()) {
Person peo = people.get(id);
valueSum -= peo.queryValue(person);
}
}


//MyPerson
for (Integer id : groups.keySet()) {
Group group = groups.get(id);
if (group.hasPerson(person)) { //如果两人在同一个组里
}
}
}


## 第三次作业

### 一、基于UML和度量的架构分析

Method CogC ev(G) iv(G) v(G)
Distance.Distance(Integer,Person) 0 1 1 1
Distance.compareTo(Object) 0 1 1 1
Distance.getDistance() 0 1 1 1
Distance.getPerson() 0 1 1 1
Main.main(String[]) 0 1 1 1
MyEmojiIdNotFoundException.MyEmojiIdNotFoundException(int) 2 1 2 2
MyEmojiIdNotFoundException.print() 0 1 1 1
MyEmojiMessage.MyEmojiMessage(int,int,Person,Group) 0 1 1 1
MyEmojiMessage.MyEmojiMessage(int,int,Person,Person) 0 1 1 1
MyEmojiMessage.addMessage(HashMap<Integer, Message>,HashMap<Integer, Integer>) 1 2 2 2
MyEmojiMessage.getEmojiId() 0 1 1 1
MyEmojiMessage.sendIndirectMessage(HashMap<Integer, Message>,HashMap<Integer, Integer>) 0 1 1 1
MyEmojiMessage.sendMessage(HashMap<Integer, Message>,HashMap<Integer, Integer>) 3 1 4 4
MyEqualEmojiIdException.MyEqualEmojiIdException(int) 2 1 2 2
MyEqualEmojiIdException.print() 0 1 1 1
MyEqualGroupIdException.MyEqualGroupIdException(int) 2 1 2 2
MyEqualGroupIdException.print() 0 1 1 1
MyEqualMessageIdException.MyEqualMessageIdException(int) 2 1 2 2
MyEqualMessageIdException.print() 0 1 1 1
MyEqualPersonIdException.MyEqualPersonIdException(int) 2 1 2 2
MyEqualPersonIdException.print() 0 1 1 1
MyEqualRelationException.MyEqualRelationException(int,int) 8 1 4 5
MyEqualRelationException.print() 0 1 1 1
MyGroup.MyGroup(int) 0 1 1 1
MyGroup.delPerson(Person) 1 1 2 2
MyGroup.equals(Object) 3 2 2 3
MyGroup.getAgeMean() 1 2 1 2
MyGroup.getAgeVar() 1 2 1 2
MyGroup.getId() 0 1 1 1
MyGroup.getSize() 0 1 1 1
MyGroup.getValueSum() 0 1 1 1
MyGroup.hasPerson(Person) 0 1 1 1
MyGroupIdNotFoundException.MyGroupIdNotFoundException(int) 2 1 2 2
MyGroupIdNotFoundException.print() 0 1 1 1
MyMessage.MyMessage(int,int,Person,Group) 0 1 1 1
MyMessage.MyMessage(int,int,Person,Person) 0 1 1 1
MyMessage.addMessage(HashMap<Integer, Message>,HashMap<Integer, Integer>) 2 2 3 3
MyMessage.dijkstra() 10 4 4 6
MyMessage.equals(Object) 3 2 2 3
MyMessage.getDis(int) 0 1 1 1
MyMessage.getGroup() 0 1 1 1
MyMessage.getId() 0 1 1 1
MyMessage.getPerson1() 0 1 1 1
MyMessage.getPerson2() 0 1 1 1
MyMessage.getSocialValue() 0 1 1 1
MyMessage.getType() 0 1 1 1
MyMessage.sendIndirectMessage(HashMap<Integer, Message>,HashMap<Integer, Integer>) 0 1 1 1
MyMessage.sendMessage(HashMap<Integer, Message>,HashMap<Integer, Integer>) 7 3 8 8
MyMessageIdNotFoundException.MyMessageIdNotFoundException(int) 2 1 2 2
MyMessageIdNotFoundException.print() 0 1 1 1
MyNetwork.MyNetwork() 0 1 1 1
MyNetwork.compareName(int,int) 2 3 2 3
MyNetwork.contains(int) 0 1 1 1
MyNetwork.containsEmojiId(int) 0 1 1 1
MyNetwork.containsMessage(int) 0 1 1 1
MyNetwork.delFromGroup(int,int) 5 4 3 4
MyNetwork.deleteColdEmoji(int) 11 1 8 8
MyNetwork.getGroup(int) 2 2 2 2
MyNetwork.getMessage(int) 2 2 2 2
MyNetwork.getPerson(int) 2 2 2 2
MyNetwork.insert(Person) 1 1 2 2
MyNetwork.isCircle(int,int) 2 3 2 3
MyNetwork.queryBlockSum() 0 1 1 1
MyNetwork.queryGroupAgeMean(int) 2 2 2 2
MyNetwork.queryGroupAgeVar(int) 2 2 2 2
MyNetwork.queryGroupPeopleSum(int) 2 2 2 2
MyNetwork.queryGroupSum() 0 1 1 1
MyNetwork.queryGroupValueSum(int) 2 2 2 2
MyNetwork.queryMoney(int) 2 2 2 2
MyNetwork.queryNameRank(int) 2 2 2 3
MyNetwork.queryPeopleSum() 0 1 1 1
MyNetwork.queryPopularity(int) 2 2 2 2
MyNetwork.querySocialValue(int) 2 2 2 2
MyNetwork.queryValue(int,int) 3 4 3 4
MyNetwork.sendIndirectMessage(int) 4 3 3 5
MyNetwork.sendMessage(int) 2 2 2 2
MyNetwork.storeEmojiId(int) 1 2 1 2
MyNoticeMessage.MyNoticeMessage(int,String,Person,Group) 0 1 1 1
MyNoticeMessage.MyNoticeMessage(int,String,Person,Person) 0 1 1 1
MyNoticeMessage.getString() 0 1 1 1
MyPerson.MyPerson(int,String,int) 0 1 1 1
MyPerson.compareTo(Person) 0 1 1 1
MyPerson.delGroup(Group) 0 1 1 1
MyPerson.equals(Object) 3 2 2 3
MyPerson.getAge() 0 1 1 1
MyPerson.getId() 0 1 1 1
MyPerson.getIterator() 0 1 1 1
MyPerson.getMessages() 0 1 1 1
MyPerson.getMoney() 0 1 1 1
MyPerson.getName() 0 1 1 1
MyPerson.getSocialValue() 0 1 1 1
MyPerson.queryValue(Person) 1 2 1 2
MyPersonIdNotFoundException.MyPersonIdNotFoundException(int) 2 1 2 2
MyPersonIdNotFoundException.print() 0 1 1 1
MyRedEnvelopeMessage.MyRedEnvelopeMessage(int,int,Person,Group) 0 1 1 1
MyRedEnvelopeMessage.MyRedEnvelopeMessage(int,int,Person,Person) 0 1 1 1
MyRedEnvelopeMessage.getMoney() 0 1 1 1
MyRedEnvelopeMessage.sendIndirectMessage(HashMap<Integer, Message>,HashMap<Integer, Integer>) 0 1 1 1
MyRedEnvelopeMessage.sendMessage(HashMap<Integer, Message>,HashMap<Integer, Integer>) 3 1 4 4
MyRelationNotFoundException.MyRelationNotFoundException(int,int) 8 1 4 5
MyRelationNotFoundException.print() 0 1 1 1
Trie.Trie() 0 1 1 1
Trie.createSon(int) 1 1 2 2
Trie.getEnd() 0 1 1 1
Trie.getSon(int) 0 1 1 1
Trie.getSum() 0 1 1 1
Trie.getSum(int) 3 3 2 3
UnionFindSet.UnionFindSet() 0 1 1 1
UnionFindSet.getFather(int) 6 5 3 5
UnionFindSet.getUnionNum() 0 1 1 1
UnionFindSet.inUnion(int,int) 0 1 1 1
UnionFindSet.insert(int) 0 1 1 1
Class OCavg OCmax WMC
Distance 1 1 4
Main 1 1 1
MyEmojiIdNotFoundException 1.5 2 3
MyEmojiMessage 1.5 3 9
MyEqualEmojiIdException 1.5 2 3
MyEqualGroupIdException 1.5 2 3
MyEqualMessageIdException 1.5 2 3
MyEqualPersonIdException 1.5 2 3
MyEqualRelationException 3 5 6
MyGroup 1.54 2 20
MyGroupIdNotFoundException 1.5 2 3
MyMessage 1.79 6 25
MyMessageIdNotFoundException 1.5 2 3
MyNetwork 2.36 8 78
MyNoticeMessage 1 1 3
MyPerson 1.3 3 26
MyPersonIdNotFoundException 1.5 2 3
MyRedEnvelopeMessage 1.4 3 7
MyRelationNotFoundException 3 5 6
Trie 1.38 3 11
UnionFindSet 1.83 5 11

//MyMessage
public void sendMessage(HashMap<Integer, Message> messages,
HashMap<Integer, Integer> emojiHeatList)
throws RelationNotFoundException, PersonIdNotFoundException {
if (this.getType() == 0 && !person1.isLinked(person2)) {
throw new MyRelationNotFoundException(person1.getId(), person2.getId());
}
if (this.getType() == 1 && !group.hasPerson(person1)) {
throw new MyPersonIdNotFoundException(person1.getId());
}
if (this.getType() == 0 && !person1.equals(person2)) {
messages.remove(this.id);
}
if (this.getType() == 1) {
messages.remove(this.id);
}
}

public int sendIndirectMessage(HashMap<Integer, Message> messages,
HashMap<Integer, Integer> emojiHeatList) {
messages.remove(id);
return dijkstra();
}

//MyRedEnvelopeMessage
public void sendMessage(HashMap<Integer, Message> messages,
HashMap<Integer, Integer> emojiHeatList)
throws RelationNotFoundException, PersonIdNotFoundException {
super.sendMessage(messages, emojiHeatList);
Person person1 = this.getPerson1();
Person person2 = this.getPerson2();
Group group = this.getGroup();
if (this.getType() == 0 && !person1.equals(person2)) {
}
if (this.getType() == 1) {
int deltaMoney = money / group.getSize();
}
}

public int sendIndirectMessage(HashMap<Integer, Message> messages,
HashMap<Integer, Integer> emojiHeatList) {
return super.sendIndirectMessage(messages, emojiHeatList);
}

//MyEmojiMessage
public void sendMessage(HashMap<Integer, Message> messages,
HashMap<Integer, Integer> emojiHeatList)
throws RelationNotFoundException, PersonIdNotFoundException {
super.sendMessage(messages, emojiHeatList);
Person person1 = this.getPerson1();
Person person2 = this.getPerson2();
if (this.getType() == 0 && !person1.equals(person2)) {
int heat = emojiHeatList.get(emojiId);
emojiHeatList.put(emojiId, heat + 1);
}
if (this.getType() == 1) {
int heat = emojiHeatList.get(emojiId);
emojiHeatList.put(emojiId, heat + 1);
}
}

public int sendIndirectMessage(HashMap<Integer, Message> messages,
HashMap<Integer, Integer> emojiHeatList) {
int heat = emojiHeatList.get(emojiId);
emojiHeatList.put(emojiId, heat + 1);
return super.sendIndirectMessage(messages, emojiHeatList);
}


### 二、实现规格所采取的设计策略

#### （一）容器的选择和使用

public class MyNetwork implements Network {
private HashMap<Integer, Person> people;
private HashMap<Integer, Group> groups;
private HashMap<Integer, Message> messages;
private HashMap<Integer, Integer> emojiHeatList;
private Trie root;
private UnionFindSet ufs;
}

public class MyMessage implements Message {
private int id;
private int socialValue;
private int type;
private Person person1;
private Person person2;
private Group group;
private PriorityQueue<Distance> pq;
private HashMap<Integer, Integer> minDis;
private HashSet<Integer> visit;
private static int INF = 0x7fffffff;
}

public class MyPerson implements Person {
private int id;
private String name;
private int age;
private HashMap<Integer, Person> acquaintance;
private HashMap<Integer, Integer> value;
private int money;
private int socialValue;
private HashMap<Integer, Group> groups;
}

public class MyEmojiMessage extends MyMessage implements EmojiMessage {
private int emojiId;
}

public class MyRedEnvelopeMessage extends MyMessage implements RedEnvelopeMessage {
private int money;
}


#### （二）性能问题分析

private int dijkstra() {
pq.clear();
minDis.clear();
visit.clear();
minDis.put(person1.getId(), 0);
while (!pq.isEmpty()) {
Distance dis = pq.poll();//取出并弹出堆顶
Person person = dis.getPerson();
int distance = dis.getDistance();
if (person.equals(person2)) { //已经访问到person2
return distance;
}
if (visit.contains(person.getId())) {//检查是否已经出堆
continue;
}
Iterator<Map.Entry<Integer, Person>> iterator = ((MyPerson)person).getIterator(); //这里我们取出																							Person中关系的迭代器
while (iterator.hasNext()) {
Person direction = iterator.next().getValue();
int oriDistance = getDis(direction.getId());
if (oriDistance > distance + person.queryValue(direction)) {//更新距离，放入堆
int newDistance = distance + person.queryValue(direction);
minDis.put(direction.getId(), newDistance);