Package upenn.junto.graph

Examples of upenn.junto.graph.Vertex


      Reducer<Text, Text, Text, Text> {
    public void reduce(Text key, Iterator<Text> values,
        OutputCollector<Text, Text> output, Reporter reporter)
        throws IOException {
      String vertexId = key.toString();
      Vertex v = new Vertex(vertexId);

      while (values.hasNext()) {
        // neighbor/self edge_weight/inject_score
        String val = values.next().toString();
        String[] fields = val.split(_kDelim);
        String msgType = fields[0];
        String trgVertexId = fields[1];

        if (msgType.equals(neighMsgType)) {
          v.setNeighbor(trgVertexId, Double.parseDouble(fields[2]));
        } else if (msgType.equals(goldLabMsgType)) {
          v.setGoldLabel(trgVertexId, Double.parseDouble(fields[2]));
        } else if (msgType.equals(injLabMsgType)) {
          v.SetInjectedLabelScore(trgVertexId,
              Double.parseDouble(fields[2]));
        }
      }
     
      // normalize transition probabilities
      v.NormalizeTransitionProbability();

      // remove dummy labels
      v.SetInjectedLabelScore(Constants.GetDummyLabel(), 0);
      v.SetEstimatedLabelScore(Constants.GetDummyLabel(), 0);

      // calculate random walk probabilities
      v.CalculateRWProbabilities(_kBeta);

      // generate the random walk probability string of the node
      String rwProbStr = Constants._kInjProb + " "
          + v.pinject() + " " + Constants._kContProb
          + " " + v.pcontinue() + " "
          + Constants._kTermProb + " "
          + v.pabandon();

      // represent neighborhood information as a string
      Object[] neighNames = v.GetNeighborNames();
      String neighStr = "";
      int totalNeighbors = neighNames.length;
      for (int ni = 0; ni < totalNeighbors; ++ni) {
        // if the neighborhood string is already too long, then
        // print it out. It is possible to split the neighborhood
        // information of a node into multiple lines. However, all
        // other fields should be repeated in all the split lines.
        if (neighStr.length() > 0 && (ni % kMaxNeighorsPerLine_ == 0)) {
          // output format
          // id gold_label injected_labels estimated_labels neighbors
          // rw_probabilities
          output.collect(
              key,
              new Text(
                  CollectionUtil.Map2String(v.goldLabels())
                      + _kDelim
                      + CollectionUtil.Map2String(v
                          .injectedLabels())
                      + _kDelim
                      + CollectionUtil.Map2String(v
                          .estimatedLabels())
                      + _kDelim + neighStr.trim()
                      + _kDelim + rwProbStr));

          // reset the neighborhood string
          neighStr = "";
        }

        neighStr += neighNames[ni] + " "
            + v.GetNeighborWeight((String) neighNames[ni]) + " ";
      }

      // print out any remaining neighborhood information, plus all other
      // info
      if (neighStr.length() > 0) {
        // output format
        // id gold_label injected_labels estimated_labels neighbors
        // rw_probabilities
        output.collect(
            key,
            new Text(CollectionUtil.Map2String(v.goldLabels())
                + _kDelim
                + CollectionUtil.Map2String(v
                    .injectedLabels())
                + _kDelim
                + CollectionUtil.Map2String(v
                    .estimatedLabels()) + _kDelim
                + neighStr.trim() + _kDelim + rwProbStr));
      }
    }
View Full Code Here


    int total_doc_cnt = 0;

    Iterator<String> vIter = g.vertices().keySet().iterator();     
    while (vIter.hasNext()) {
      String vName = vIter.next();
      Vertex v = g.vertices().get(vName);
     
      if (v.isTestNode()) {
        double mrr = v.GetMRR();
        ++total_doc_cnt;
        doc_mrr_sum += mrr;
        if (mrr == 1) {
          ++correct_doc_cnt;
        }
View Full Code Here

    int totalVertices = 0;
    int maxDegree = Integer.MIN_VALUE;
    int minDegree = Integer.MAX_VALUE;

    for (String vName : g.vertices().keySet()) {
      Vertex v = g.vertices().get(vName);
      ++totalVertices;
     
      int degree = v.GetNeighborNames().length;
      if (degree > maxDegree) { maxDegree = degree; }
      if (degree < minDegree) { minDegree = degree; }

      totalEdges += v.neighbors().size();
     
      if (v.isSeedNode()) { ++totalSeedNodes; }
      if (v.isTestNode()) { ++totalTestNodes; }
      if (v.isSeedNode() && v.isTestNode()) { ++totalSeedAndTestNodes; }
    }
   
    String retStr = "Total seed vertices: " + totalSeedNodes + "\n";
    retStr += "Total test vertices: " + totalTestNodes + "\n";
    retStr += "Total seed vertices which are also test vertices: " + totalSeedAndTestNodes + "\n";
View Full Code Here

    int total_doc_cnt = 0;

    Iterator<String> vIter = g.vertices().keySet().iterator();     
    while (vIter.hasNext()) {
      String vName = vIter.next();
      Vertex v = g.vertices().get(vName);
     
      if (v.isTestNode()) {
        double mrr = v.GetMRR();
        ++total_doc_cnt;
        doc_mrr_sum += mrr;
      }
    }
View Full Code Here

   
    int totalProcessed = 0;
   
    Iterator<Vertex> vIter = g.vertexSet().iterator();
    while (vIter.hasNext()) {
      Vertex v = vIter.next();
      if (!v.isSeedNode()) {
        continue;
      }
     
      ++totalProcessed;
      if (totalProcessed % 1000 == 0) {
        logger.info("Processed: " + totalProcessed + " curr_dia: " + diameter);
      }
     
      KShortestPaths<Vertex,DefaultWeightedEdge> ksp = new KShortestPaths(g, v, 1);
      // kShortestPathMap.put(v, new KShortestPaths(g, v, _kPrime));
     
      Iterator<Vertex> vIter2 = g.vertexSet().iterator();
      while (vIter2.hasNext()) {
        Vertex nv = vIter2.next();
       
        // skip self comparison
        if (v.equals(nv)) { continue; }

        List<GraphPath<Vertex,DefaultWeightedEdge>> paths = ksp.getPaths(nv);
View Full Code Here

    int total_doc_cnt = 0;

    Iterator<String> vIter = g.vertices().keySet().iterator();     
    while (vIter.hasNext()) {
      String vName = vIter.next();
      Vertex v = g.vertices().get(vName);
     
      if (v.isSeedNode()) {
        double mrr = v.GetMRR();
        ++total_doc_cnt;
        doc_mrr_sum += mrr;
      }
    }
View Full Code Here

    int totalCount = 0;

    Iterator<String> vIter = g.vertices().keySet().iterator();     
    while (vIter.hasNext()) {
      String vName = vIter.next();
      Vertex v = g.vertices().get(vName);
     
      if (v.isTestNode()) {
        totalMSE += v.GetMSE();
        ++totalCount;
      }
    }

    return (Math.sqrt((1.0 * totalMSE) / totalCount));
View Full Code Here

TOP

Related Classes of upenn.junto.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.