Package org.ictclas4j.bean

Examples of org.ictclas4j.bean.Queue


      for (int i = 0; i < pathWeight.length; i++)
        for (int j = 0; j < pathWeight[i].length; j++)
          pathWeight[i][j] = Utility.INFINITE_VALUE;

      for (int i = 0; i < vertex; i++) {
        parent[i] = new Queue();
      }
    }
  }
View Full Code Here


        // �õ�ͬһ�е�����Ԫ��
        ArrayList<SegNode> colSgs = biSegGraph.getNodes(cur, true);
        if (colSgs == null || colSgs.size() == 0)
          return;

        Queue queWork = new Queue();
        for (SegNode seg : colSgs) {
          preNode = seg.getRow();
          weight = seg.getWeight();

          if (preNode == 0) {
            queWork.push(new QueueNode(preNode, 0, weight));

          } else {
            if (pathWeight[preNode][0] != Utility.INFINITE_VALUE)
              queWork.push(new QueueNode(preNode, 0, weight + pathWeight[preNode][0]));
          }

        }

        // ��¼ÿһ���ڵ��N��ǰ����Ȩ��
        QueueNode minNode = null;
        int pathIndex = 0;
        while ((minNode = queWork.pop()) != null && pathIndex < pathCount) {
          pathWeight[cur][pathIndex] = minNode.getWeight();
          parent[cur].push(minNode);
          logger.debug("pathWeight[" + cur + "][" + pathIndex + "]:" + pathWeight[cur][pathIndex]);
          logger.debug("parent[" + cur + "]:" + parent[cur]);
          pathIndex++;
View Full Code Here

  public ArrayList<ArrayList<Integer>> getPaths() {
    ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
    ArrayList<Integer> onePath = null;// һ���ִ�·��

    Queue queResult = null;
    int curNode, curIndex = 0;
    int pathIndex = 0;

    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;
            }
          }
        }
      }
View Full Code Here

      for (int i = 0; i < pathWeight.length; i++)
        for (int j = 0; j < pathWeight[i].length; j++)
          pathWeight[i][j] = Utility.INFINITE_VALUE;

      for (int i = 0; i < vertex; i++) {
        parent[i] = new Queue();
      }
    }
  }
View Full Code Here

        // �õ�ͬһ�е�����Ԫ��
        ArrayList<SegNode> colSgs = biSegGraph.getNodes(cur, true);
        if (colSgs == null || colSgs.size() == 0)
          return;

        Queue queWork = new Queue();
        for (SegNode seg : colSgs) {
          preNode = seg.getRow();
          weight = seg.getValue();

          if (preNode == 0) {
            queWork.push(new QueueNode(preNode, 0, weight));

          } else {
            if (pathWeight[preNode][0] != Utility.INFINITE_VALUE)
              queWork.push(new QueueNode(preNode, 0, weight + pathWeight[preNode][0]));
          }

        }

        // ��¼ÿһ���ڵ��N��ǰ����Ȩ��
        QueueNode minNode = null;
        int pathIndex = 0;
        while ((minNode = queWork.pop()) != null && pathIndex < pathCount) {
          pathWeight[cur][pathIndex] = minNode.getWeight();
          parent[cur].push(minNode);
          logger.debug("pathWeight[" + cur + "][" + pathIndex + "]:" + pathWeight[cur][pathIndex]);
          logger.debug("parent[" + cur + "]:" + parent[cur]);
          pathIndex++;
View Full Code Here

  public ArrayList<ArrayList<Integer>> getPaths() {
    ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
    ArrayList<Integer> onePath = null;// һ���ִ�·��

    Queue queResult = null;
    int curNode, curIndex = 0;
    int pathIndex = 0;

    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();
          }
          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;
            }
          }
        }
      }
View Full Code Here

TOP

Related Classes of org.ictclas4j.bean.Queue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.