Package org.patika.mada.graph

Examples of org.patika.mada.graph.Node


    for (Edge edge : node.getUpstream())
    {
      // Do not consider non-causative edges
      if (!edge.isDirected()) continue;

      Node neigh = edge.getSourceNode();

      // Do it if will not cause a cycle

      if (neigh != target && !neigh.hasLabel(ON_PATH))
      {
        neigh.putLabel(EDGE, edge);
        neigh.putLabel(ON_PATH, true);
        path.addFirst(neigh, neigh.isBreadthNode());

        checkAndProceed(neigh, target, path, TOWARDS_BOTHWAYS);

        path.removeFirst(neigh.isBreadthNode());
        neigh.removeLabel(ON_PATH);
        neigh.removeLabel(EDGE);
      }
    }
  }
View Full Code Here


  public void removeLabels(Collection labels)
  {
    for (Object o : getNodes())
    {
      Node node = (Node) o;

      for (Object label : labels)
      {
        node.removeLabel(label);
      }
    }
  }
View Full Code Here

  {
    interactionMap = new HashMap<interaction, Collection<GraphObject>>();

    for (Object o : getNodes())
    {
      Node node = (Node) o;

      interaction inter = null;

      if (node instanceof Conversion)
      {
View Full Code Here

  {
    entityToNodeMap = new HashMap<physicalEntity, List<Node>>();

    for (Object o : getNodes())
    {
      Node node = (Node) o;

       if (node instanceof Actor)
      {
        getRelatedNodeList(((Actor) node).getEntity()).add(node);
      }
View Full Code Here

   * Assigns distances to and enqueues downstream or upstream according to direction.
   */
  private void bfsStep(LinkedList<Node> queue, Node root, boolean direction)
  {
    // Next node in queue
    Node node = queue.poll();

    // Get previously assigned distance. This will not change, but will be used for labeling
    // neighbors.

    assert !isVisited(node) || node.hasLabel(VISITED_WO_CH) || node.hasLabel(VISITED_WO_PR);
   
    int d = !isVisited(node) ? getDistance(node, root, direction) :
      (Integer) node.getLabel(TEMP_DIST);

    // Put parents in front of the queue if not already coming from a parent.
   
    if (!node.hasLabel(PARENT_LOCK) && (!isVisited(node) || node.hasLabel(VISITED_WO_PR)))
    {
      for (Node parent : node.getParents())
      {
        if (!isVisited(parent) || parent.hasLabel(VISITED_WO_PR))
        {
          if (queue.contains(parent))
          {
            queue.remove(parent);
          }
          queue.addFirst(parent);
         
          if (!isVisited(parent))
          {
            parent.putLabel(CHILD_LOCK);
            putDistance(parent, root, direction, d);
          }
          else
          {
            parent.putLabel(TEMP_DIST, d);
          }
        }
      }
    }
   
    // Put children in front of the queue if not already coming from a child.
   
    if (!node.hasLabel(CHILD_LOCK) && (!isVisited(node) || node.hasLabel(VISITED_WO_CH)))
    {
      for (Node child : node.getChildren())
      {
        if (!isVisited(child) || child.hasLabel(VISITED_WO_CH))
        {
          if (queue.contains(child))
          {
            queue.remove(child);
          }
          queue.addFirst(child);
         
          if (!isVisited(child))
          {
            putDistance(child, root, direction, d);
            child.putLabel(PARENT_LOCK);           
          }
          else
          {
            child.putLabel(TEMP_DIST, d);
          }
        }
      }
    }
   
    // Proceed to up/downstream only if not reached the distance limit
   
    if (d < limit && !isVisited(node))
    {
      // Iterate neighbors
 
      for (Edge edge : getEdges(node, direction))
      {
        // Do not consider non-causative edges
        if (!edge.isCausative()) continue;

        Node neigh = getEdgeEnd(edge, direction);

        boolean step = neigh.isBreadthNode() && edge.isBreadthEdge();
       
        // Process only if neighbor is not already in the queue.
       
        if (!queue.contains(neigh))
        {
          if (!isVisited(neigh))
          {
            putDistance(neigh, root, direction, step ? d+1 : d);
   
            // Enqueue neighbor

            if (step)
            {
              queue.addLast(neigh);
            }
            else
            {
              if (queue.contains(neigh))
              {
                queue.remove(neigh);
              }
              queue.addFirst(neigh);
            }
          }
          else if (neigh.hasLabel(VISITED_WO_CH) || neigh.hasLabel(VISITED_WO_PR))
          {
            neigh.putLabel(TEMP_DIST, step ? d+1 : d);

            if (step)
            {
              queue.addLast(neigh);
            }
View Full Code Here

    {
      Object model = ((EditPart)selectedObjectsIterator.next()).getModel();

      if (model instanceof Node)
      {
        Node node = (Node) model;

        //if node is CompexMember, then get its parent
        if (node instanceof ComplexMember)
        {
          node = node.getParents().iterator().next();
        }

        selectedObjects.add(node);
      }
    }
View Full Code Here

    {
      // Do not consider non-causative edges
      if (!edge.isCausative()) continue;

      int edgeSign = edge.getSign();
      Node neigh = edge.getSourceNode();

      // Do it if will not cause a cycle
     
      if (neigh != target && !neigh.hasLabel(ON_PATH) && !forbidden.contains(neigh))
      {
        // If this is the last reaction, then it should be a transcriptional relation
        if (false)//node == target && neigh.isEvent())
        {
          if (!neigh.isTranscriptionEvent()) continue;
        }
       
        Set<Node> newDestSet = filterDestinationSources(neigh, target, destSet);

        // Proceed only if there is some source to go.
        if (!newDestSet.isEmpty() || destSet.contains(neigh))
        {
          boolean distIncr = neigh.isBreadthNode() && edge.isBreadthEdge();

          Set<Node> tabu = keepDifference(forbidden, neigh.getTabuNodes());
          forbidden.addAll(tabu);
          neigh.putLabel(EDGE, edge);
          neigh.putLabel(ON_PATH, true);
          path.addFirst(neigh, distIncr);
         
          checkAndProceed(neigh, target, path, sign * edgeSign, newDestSet, forbidden,
            TOWARDS_BOTHWAYS);
         
          path.removeFirst(distIncr);
          neigh.removeLabel(ON_PATH);
          neigh.removeLabel(EDGE);
          forbidden.removeAll(tabu);
        }
      }
    }
  }
View Full Code Here

   */
  private boolean sameEntityWithAMember(Complex c, Node node)
  {
    for (Object o : c.getChildren())
    {
      Node child = (Node) o;

      if (child.sameEntity(node))
      {
        return true;
      }
    }
    return false;
View Full Code Here

    {
      Iterator<Node> iter = diff.iterator();

      while (iter.hasNext())
      {
        Node node = iter.next();

        if (set.contains(node))
        {
          iter.remove();
        }
View Full Code Here

    // Run BFS forward or backward till queue is not empty

    while (!queue.isEmpty())
    {
      Node node = queue.poll();
      BFS_directed(node, direction, queue);
    }
  }
View Full Code Here

TOP

Related Classes of org.patika.mada.graph.Node

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.