Package edu.uci.ics.jung.graph

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


    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

        if (answer.firstElem == AbstractOracle.USER_CANCELLED)
        {
          System.out.println("CANCELLED");
          return null;
        }
        Vertex tempVertex = getVertex(temp, question);
        if(answer.firstElem == AbstractOracle.USER_ACCEPTED){
          sPlus.add(question);
         
          if(!DeterministicDirectedSparseGraph.isAccept(tempVertex))
          {
View Full Code Here

 
  public static Vertex getTempRed(DirectedSparseGraph model, Vertex r, DirectedSparseGraph temp){
    DijkstraShortestPath p = new DijkstraShortestPath(model);
    List<Edge> pathToRed = p.getPath(DeterministicDirectedSparseGraph.findInitial(model), r);
    Set<List<String>> pathToRedStrings = new HashSet<List<String>>();
    Vertex tempRed = null;
    if(!pathToRed.isEmpty()){
      pathToRedStrings = getPaths(pathToRed);
      List<String> prefixString = (List<String>)pathToRedStrings.toArray()[0];
      tempRed = getVertex(temp, prefixString);
    }
View Full Code Here

      tempRed = DeterministicDirectedSparseGraph.findInitial(temp);
    return tempRed;
  }
 
  protected List<List<String>> generateQuestions(DirectedSparseGraph model, DirectedSparseGraph temp, OrigStatePair pair){
    Vertex q = pair.getQ();
    Vertex r = pair.getR();
    if(q==null || r ==null)
      return new ArrayList<List<String>>();
    DijkstraShortestPath p = new DijkstraShortestPath(temp);
    Vertex tempRed = getTempRed(model, r, temp);
    Vertex tempInit = DeterministicDirectedSparseGraph.findInitial(temp);
    Set<List<String>> prefixes = new HashSet<List<String>>();
    if(!tempRed.equals(tempInit)){
      List<Edge> prefixEdges = p.getPath(tempInit, tempRed);
      prefixes = getPaths(prefixEdges);
    }
    Set<List<String>> suffixes = computeSuffixes(tempRed, temp);
    List<List<String>> questions =new ArrayList<List<String>>();
    questions.addAll(mergePrefixWithSuffixes(prefixes, suffixes));
    Edge loopEdge = findEdge(tempRed, tempRed);
    if(loopEdge!=null){
      Collection<String> looplabels = (Collection<String>)loopEdge.getUserDatum(JUConstants.LABEL);
      questions.addAll(mergePrefixWithSuffixes(prefixes, looplabels,suffixes));
    }
   
    DirectedSparseGraph questionPrefixes = augmentPTA(DeterministicDirectedSparseGraph.initialise(), questions, true);
    Iterator<Vertex> questionIt = getEndPoints(questionPrefixes).iterator();
    p = new DijkstraShortestPath(questionPrefixes);
    questions =new ArrayList<List<String>>();
    Vertex init = DeterministicDirectedSparseGraph.findInitial(questionPrefixes);
    while(questionIt.hasNext()){
      List<Edge> edgePath = p.getPath(init, questionIt.next());
      Set<List<String>> pathsToPoint = getPaths(edgePath);
      if(pathsToPoint.isEmpty())
        continue;
      List<String> pathToPoint = (List<String>)getPaths(edgePath).toArray()[0];
      Vertex tempV = getVertex(temp, pathToPoint);
      Vertex v = getVertex(model, pathToPoint);
      if(v == null)
        questions.add(pathToPoint);
      else if(Test_Orig_RPNIBlueFringeLearner.different(new OrigStatePair(v, tempV)))
        questions.add(pathToPoint);
     
View Full Code Here

 
  private static Set<Vertex> getEndPoints(DirectedSparseGraph g){
    Set<Vertex> returnSet = new HashSet<Vertex>();
    Iterator<Vertex> vertexIt = g.getVertices().iterator();
    while(vertexIt.hasNext()){
      Vertex v = vertexIt.next();
      if(v.getSuccessors().isEmpty())
        returnSet.add(v);
    }
    return returnSet;
  }
View Full Code Here

      if (!(vertToClone instanceof Vertex))
        throw new IllegalArgumentException("Cannot clone vertex which is neither a CmpVertex nor Vertex, what was passed is "+vertToClone);
      if (!conf.isAllowedToCloneNonCmpVertex())
        throw new IllegalArgumentException("Cannot clone a non-CmpVertex - prohibited using configuration");
     
      Vertex srcVert = (Vertex)vertToClone;
      if (!srcVert.containsUserDatumKey(JUConstants.LABEL))
        throw new IllegalArgumentException("vertex "+srcVert+" is not labelled");
     
      // Copying the attributes associated with the vertex
      Object label = srcVert.getUserDatum(JUConstants.LABEL);
      if (label instanceof VertexID)
        result = generateNewCmpVertex((VertexID)label, conf);
      else
        if (label instanceof String)
          result = generateNewCmpVertex(VertexID.parseID((String)label), conf);
        else
          throw new IllegalArgumentException("vertex with label "+label+" has an unsupported type");

      result.setAccept(DeterministicDirectedSparseGraph.isAccept(srcVert));
      if (srcVert.containsUserDatumKey(JUConstants.COLOUR))
        result.setColour((JUConstants)srcVert.getUserDatum(JUConstants.COLOUR));
      if (srcVert.containsUserDatumKey(JUConstants.HIGHLIGHT))
        result.setHighlight(true);
      if (srcVert.containsUserDatumKey(JUConstants.ORIGSTATE))
        result.setOrigState((VertexID)srcVert.getUserDatum(JUConstants.ORIGSTATE));
      if (srcVert.containsUserDatumKey(JUConstants.DEPTH))
        result.setDepth((Integer)srcVert.getUserDatum(JUConstants.DEPTH));
    }
    return result;
  }
View Full Code Here

  protected Graph removeNegatives(Graph g){
    Iterator<Vertex> vertexIt = g.getVertices().iterator();
    HashSet<Vertex> remove = new HashSet<Vertex>();
    while(vertexIt.hasNext()){
      Vertex v = vertexIt.next();
      if(!DeterministicDirectedSparseGraph.isAccept(v)&&!DeterministicDirectedSparseGraph.isInitial(v))
        remove.add(v);
    }
    Iterator<Vertex> removeIt = remove.iterator();
    while(removeIt.hasNext()){
View Full Code Here

    for(Vertex v: DeterministicDirectedSparseGraph.findVertices(JUConstants.COLOUR, JUConstants.RED, model))
    {
      Iterator<DirectedSparseEdge>neighbourIt = v.getOutEdges().iterator();
      while(neighbourIt.hasNext()){
        DirectedSparseEdge next = neighbourIt.next();
        Vertex neighbour = next.getDest();
        JUConstants neighbourColour = (JUConstants)neighbour.getUserDatum(JUConstants.COLOUR);
        if(neighbourColour!=null){
          if(neighbourColour == JUConstants.RED)
            continue;
        }
        neighbour.setUserDatum(JUConstants.COLOUR, JUConstants.BLUE, UserData.SHARED);
        blues.add(neighbour);
       
      }
    }
    //updateGraph(model);
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.