Package edu.uci.ics.jung.graph

Examples of edu.uci.ics.jung.graph.Vertex


        double translateY = 0.0;
        boolean dontSend = false;
        // by default activate default view
        boolean activateDefaultView = true;
        boolean isLoadDefaultViewsList = false;
        Vertex vertex = null;
        //boolean translateSet = false;
        ArrayList <String>views = new ArrayList<String>();
        for (Object n: l) {
            if (n instanceof ErrorMapper) {               
                MapperEvent me = new MapperEvent(this);
                me.setMapperType(MapperActionType.DisplayError);
                Date d = new Date(System.currentTimeMillis());
                NexsmLog nl = new NexsmLog(d, NexsmLogType.Critical, "Puller error",
                            ((ErrorMapper)n).getMessage());
                me.setParams(nl);
                fireMapperActionRequested(me);
            } else if (n instanceof LoggedInUser) {
                LoggedInUser li = (LoggedInUser)n;
                if (li.isLoggedIn() && li.isConfigAllowed()) {
                    MapperEvent me = new MapperEvent(this);
                    me.setMapperType(MapperActionType.DisplayToolbar);
                    me.setParams(true);
                    fireMapperActionRequested(me);
                }
                _li.setLoggedIn(li.isLoggedIn());
                _li.setConfigAllowed(li.isConfigAllowed());
            } else if (n instanceof MapHost) { // response to loadMap
                mh = (MapHost)n;
                // TODO change this to use the selected view in MapApplet
                vertex = _graphManager.getVertex(mh.getName());
                if (viewName.length() > 0 && loadMap) {
                    if (vertex != null) {
                        _graphManager.moveVertex(vertex, mh.getCoordinates(), viewName);
                        if (mh.isHidden()) {
                            _graphManager.hideVertex(vertex, viewName);
                        } else {
                            _graphManager.showVertex(vertex, viewName);
                        }
                        if (mh.isLocked()) {
                            _graphManager.lockVertex(vertex, viewName);
                        }
                        if (mh.getLabelLocation() != null) {
                            vertex.setUserDatum("labelLocation", mh.getLabelLocation(), UserData.REMOVE);
                        }
                    }
                } else {
                    if (!mapHostErrorSent) {
                        MapperEvent me = new MapperEvent(this);
View Full Code Here


    // second pass - checking if any transitions need to be added.
    Set<String> outLabels = new HashSet<String>();
    Iterator<Vertex> vertexIt = (Iterator<Vertex>)g.getVertices().iterator();
    while(vertexIt.hasNext() && !transitionsToBeAdded)
    {
      Vertex v = vertexIt.next();
      outLabels.clear();
      Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
      while(outEdgeIt.hasNext()){
        DirectedSparseEdge outEdge = outEdgeIt.next();
        outLabels.addAll( (Set<String>)outEdge.getUserDatum(JUConstants.LABEL) );
      }
      transitionsToBeAdded = !alphabet.equals(outLabels);
    }
   
    if (transitionsToBeAdded)
    {
      // third pass - adding transitions
      g.addVertex(rejectVertex);
      vertexIt = (Iterator<Vertex>)g.getVertices().iterator();
      while(vertexIt.hasNext())
      {
        Vertex v = vertexIt.next();
        if (v != rejectVertex)
        {// no transitions should start from the reject vertex
          Set<String> outgoingLabels = new TreeSet<String>();outgoingLabels.addAll(alphabet);
         
          Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
          while(outEdgeIt.hasNext()){
            DirectedSparseEdge outEdge = outEdgeIt.next();
            outgoingLabels.removeAll( (Set<String>)outEdge.getUserDatum(JUConstants.LABEL) );
          }
          if (!outgoingLabels.isEmpty())
View Full Code Here

   * @param pta the graph to operate on.
   */
  public static void numberVertices(DirectedSparseGraph pta){
    Iterator<Vertex> vertexIt = getBFSList(pta).iterator();
    while(vertexIt.hasNext()){
      Vertex v = vertexIt.next();
      v.removeUserDatum(JUConstants.LABEL);// since we'd like this method to run multiple times, once immediately after initialisation and subsequently when sPlus and sMinus are added.
      v.addUserDatum(JUConstants.LABEL, v.toString(), UserData.SHARED);
    }
  }
View Full Code Here

    }
  }

  public static List<Vertex> getBFSList(Graph g){
    List<Vertex> queue = new LinkedList<Vertex>();
    Vertex init = DeterministicDirectedSparseGraph.findInitial(g);
    queue.add(0,init);
    int i=0;
    int j= queue.size();
    Set<Vertex> done = new HashSet<Vertex>();
    while(i<j){
      DirectedSparseVertex v = (DirectedSparseVertex)queue.get(i);
      done.add(v);
      Iterator succIt = v.getSuccessors().iterator();
      while(succIt.hasNext()){
        Vertex succ = (Vertex)succIt.next();
        if(!done.contains(succ))
          queue.add(succ);
      }
      j = queue.size();
      i++;
View Full Code Here

    if (value == null)
      throw new IllegalArgumentException("value to search for cannot be null");
   
    Iterator<Vertex> vertexIt = g.getVertices().iterator();
    while(vertexIt.hasNext()){
      Vertex v = vertexIt.next();
      if(v.getUserDatum(property) == null)
        continue;
      if(v.getUserDatum(property).equals(value))
        return v;
    }
    return null;
  }
View Full Code Here

   * @return initial vertex, null if not found.
   */
  public static Vertex findInitial(Graph g){
    Iterator<Vertex> vertexIt = g.getVertices().iterator();
    while(vertexIt.hasNext()){
      Vertex v = vertexIt.next();
      if (isInitial(v))
        return v;
    }
    return null;
  }
View Full Code Here

  public static Set<Vertex> findVertices(JUConstants property, Object value, Graph g){
    Set<Vertex> vertices = new HashSet<Vertex>();
    Iterator<Vertex> vertexIt = g.getVertices().iterator();
    while(vertexIt.hasNext()){
      Vertex v = vertexIt.next();
      if(v.getUserDatum(property) == null)
        continue;
      if(v.getUserDatum(property).equals(value))
        vertices.add(v);
    }
    return vertices;
  }
View Full Code Here

    // second pass - checking if any transitions need to be added.
    Set<String> outLabels = new HashSet<String>();
    Iterator<Vertex> vertexIt = (Iterator<Vertex>)g.getVertices().iterator();
    while(vertexIt.hasNext() && !transitionsToBeAdded)
    {
      Vertex v = vertexIt.next();
      outLabels.clear();
      Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
      while(outEdgeIt.hasNext()){
        DirectedSparseEdge outEdge = outEdgeIt.next();
        outLabels.addAll( (Set<String>)outEdge.getUserDatum(JUConstants.LABEL) );
      }
      transitionsToBeAdded = !alphabet.equals(outLabels);
    }
   
    if (transitionsToBeAdded)
    {
      // third pass - adding transitions
      g.addVertex(rejectVertex);
      vertexIt = (Iterator<Vertex>)g.getVertices().iterator();
      while(vertexIt.hasNext())
      {
        Vertex v = vertexIt.next();
        if (v != rejectVertex)
        {// no transitions should start from the reject vertex
          Set<String> outgoingLabels = new TreeSet<String>();outgoingLabels.addAll(alphabet);
         
          Iterator<DirectedSparseEdge>outEdgeIt = v.getOutEdges().iterator();
          while(outEdgeIt.hasNext()){
            DirectedSparseEdge outEdge = outEdgeIt.next();
            outgoingLabels.removeAll( (Set<String>)outEdge.getUserDatum(JUConstants.LABEL) );
          }
          if (!outgoingLabels.isEmpty())
View Full Code Here

   * @param pta the graph to operate on.
   */
  public static void numberVertices(DirectedSparseGraph pta){
    Iterator<Vertex> vertexIt = getBFSList(pta).iterator();
    while(vertexIt.hasNext()){
      Vertex v = vertexIt.next();
      v.removeUserDatum(JUConstants.LABEL);// since we'd like this method to run multiple times, once immediately after initialisation and subsequently when sPlus and sMinus are added.
      v.addUserDatum(JUConstants.LABEL, v.toString(), UserData.SHARED);
    }
  }
View Full Code Here

    }
  }

  public static List<Vertex> getBFSList(Graph g){
    List<Vertex> queue = new LinkedList<Vertex>();
    Vertex init = DeterministicDirectedSparseGraph.findInitial(g);
    queue.add(0,init);
    int i=0;
    int j= queue.size();
    Set<Vertex> done = new HashSet<Vertex>();
    while(i<j){
      DirectedSparseVertex v = (DirectedSparseVertex)queue.get(i);
      done.add(v);
      Iterator succIt = v.getSuccessors().iterator();
      while(succIt.hasNext()){
        Vertex succ = (Vertex)succIt.next();
        if(!done.contains(succ))
          queue.add(succ);
      }
      j = queue.size();
      i++;
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.graph.Vertex

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.