shortPath();
if (vertex > 0) {
queResult = new Queue();
queResult.push(new QueueNode(vertex - 1, 0, 0));
curNode = vertex - 1;
curIndex = 0;
while (!queResult.isEmpty()) {
while (curNode > 0) {
// Get its parent and store them in nParentNode,nParentIndex
QueueNode qn = parent[curNode].pop(false);
if (qn == null)
qn = parent[curNode].top();
if (qn != null) {
curNode = qn.getParent();
curIndex = qn.getIndex();
}
else
break;
if (curNode > 0)
queResult.push(new QueueNode(curNode, curIndex, 0));
}
if (curNode == 0) {
// ���һ���ִ�·��
QueueNode qn = null;
onePath = new ArrayList<Integer>();
onePath.add(curNode);
while ((qn = queResult.pop(false)) != null)
onePath.add(qn.getParent());
result.add(onePath);
queResult.resetIndex();
pathIndex++;// Ѱ����һ���ζ�·��
if (pathIndex == pathCount)
break;
// ����ҵ�����һ��ǰ���Ľڵ㣬����������ǰ��ѹ��ջ��
while ((qn = queResult.pop()) != null) {
curNode = qn.getParent();
QueueNode next = parent[curNode].pop(false);
if (next != null) {
curNode = next.getParent();
next.setWeight(0);
queResult.push(qn);
queResult.push(next);
break;
}
}