com.ibm.wala.util.graph.Graph.getPredNodes()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中com.ibm.wala.util.graph.Graph.getPredNodes()方法的一些代码示例,展示了Graph.getPredNodes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getPredNodes()方法的具体详情如下:
包路径:com.ibm.wala.util.graph.Graph
类名称:Graph
方法名:getPredNodes

Graph.getPredNodes介绍

暂无

代码示例

代码示例来源:origin: com.ibm.wala/com.ibm.wala.util

/**
 * For now, this returns nodes in no particular order! Fix this when needed.
 */
@Override
public Iterator<T> getPredNodes(T N) throws IllegalArgumentException {
 return delegate.getPredNodes(N);
}

代码示例来源:origin: wala/WALA

/**
 * For now, this returns nodes in no particular order! Fix this when needed.
 */
@Override
public Iterator<T> getPredNodes(T N) throws IllegalArgumentException {
 return delegate.getPredNodes(N);
}

代码示例来源:origin: wala/WALA

/**
 * For now, this returns nodes in no particular order! Fix this when needed.
 */
@Override
public Iterator<T> getPredNodes(T N) throws IllegalArgumentException {
 return delegate.getPredNodes(N);
}

代码示例来源:origin: wala/WALA

@Override
public Iterator<T> getPredNodes(T N) throws IllegalArgumentException {
 return delegate.getPredNodes(N);
}

代码示例来源:origin: wala/WALA

@Override
public Iterator<T> getPredNodes(T N) throws IllegalArgumentException {
 return delegate.getPredNodes(N);
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.util

@Override
public Iterator<T> getPredNodes(T N) throws IllegalArgumentException {
 return delegate.getPredNodes(N);
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.util

@Override
public Iterator<T> getPredNodes(T n) {
 return new FilterIterator<>(g.getPredNodes(n), p);
}

代码示例来源:origin: wala/WALA

@Override
public Iterator<T> getPredNodes(T n) {
 return new FilterIterator<>(g.getPredNodes(n), p);
}

代码示例来源:origin: wala/WALA

@Override
public Iterator<T> getPredNodes(T n) {
 return new FilterIterator<>(g.getPredNodes(n), p);
}

代码示例来源:origin: Quetzal-RDF/quetzal

protected void traverseLattice(TaxoNode node, Set<TaxoNode> alreadyVisited, boolean fromSuperToSub) {
  if (alreadyVisited == null) {
    alreadyVisited = new HashSet<TaxonomyBuilder<T>.TaxoNode>();
  }
  //Set<TaxoNode> ret = new HashSet<TaxonomyBuilder<T>.TaxoNode>();
  List<TaxoNode> queue = new LinkedList<TaxonomyBuilder<T>.TaxoNode>();
  queue.add(node);
  while (!queue.isEmpty()) {
    TaxoNode t = queue.remove(0);
    //ret.add(t);
    alreadyVisited.add(t);
    for (Iterator<? extends TaxoNode> it = fromSuperToSub? lattice.getPredNodes(t): lattice.getSuccNodes(t);it.hasNext();) {
      TaxoNode next = it.next();
      if (!alreadyVisited.contains(next)) {
        queue.add(next);
      }
    }
  }
  //return ret;
}
/**

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
 * Recursive method of getDist, updating the Map _dist
 * @param _tgt
 * @param _dist
 * @return
 */
private Map<Integer, Integer> computeDist(Integer _tgt, Map<Integer, Integer> _dist) {
  // For all predecessor nodes of _tgt, distance to the original target plus one
  final int distance = _dist.get(_tgt) + 1;
  // Loop all predecessor nodes of _tgt
  final Iterator<Integer> pred_nodes = this.idgraph.getPredNodes(_tgt);
  while (pred_nodes.hasNext()) {
    final Integer prednode = pred_nodes.next();
    // Only update _dist when the distance becomes shorter (-1 = infinite)
    // HP, 29.11: Changed from -1 for infinite to Integer.MAX_VALUE, which safes one comparison
    if (_dist.get(prednode) > distance) {					
      _dist.put(prednode, distance);
      _dist = this.computeDist(prednode, _dist);
    }    
  }
  return _dist;
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
   * Recursive method of getAllEdges, update the Map _edges
   * 
   * @param _tgt
   * @param _edges
   * @return
   */
  private void computeAllEdges(Integer _tgt) {
    Iterator<Integer> predNodes = this.graph.getPredNodes(_tgt);
    Integer prednode = null;
    while (predNodes.hasNext()) {
      prednode = predNodes.next();
      HashSet<Integer> newedge = this.edges.get(prednode);
      if (newedge == null) {
        newedge = new HashSet<Integer>();
      }
      if (!newedge.contains(_tgt)) {
        newedge.add(_tgt);
        this.edges.put(prednode, newedge);
        computeAllEdges(prednode);
      }
    }
  }    
}

代码示例来源:origin: SAP/vulnerability-assessment-tool

/**
 * Recursive method of getShortestPath, updating the Map _path
 * @param _tgt
 * @param _paths
 * @return
 */
private Map<Integer, LinkedList<Integer>> computeShortestPath(Integer _tgt, Map<Integer, LinkedList<Integer>> _paths, final Set<Integer> _stop_nodes) {
  final LinkedList<Integer> new_path = new LinkedList<Integer>();
  new_path.addAll(_paths.get(_tgt));
  // Create the new path by adding the current target node (i.e. _tgt)
  new_path.add(_tgt);
  final int new_path_length = new_path.size();
  final Iterator<Integer> pred_nodes = this.idgraph.getPredNodes(_tgt);
  while (pred_nodes.hasNext()) {
    final int prednode = pred_nodes.next();
    // Only update when there is no path or when the path becomes shorter 
    if ( _paths.get(prednode) == null || (_paths.get(prednode).size() > new_path_length) ) {					
      _paths.put(prednode, new_path);
      // Only continue searching if there are no stop nodes, or none of them has been reached yet
      if(_stop_nodes==null || !this.existsPath(_paths, _stop_nodes))
        _paths = this.computeShortestPath(prednode, _paths, _stop_nodes);
    }
  }
  return _paths;
}

代码示例来源:origin: wala/WALA

public static <T> void assertColoring(Graph<T> G, Map<T,Integer> colors, boolean fullColor) {
 for(T n : G) {
  for(T succ : Iterator2Iterable.make(G.getSuccNodes(n))) {
   if (!fullColor &&  (!colors.containsKey(n) || !colors.containsKey(succ)) ) {
    continue;
   }
   Assert.assertTrue(n + " and succ: " + succ + " have same color: " + colors.get(n).intValue(), colors.get(n).intValue() != colors.get(succ).intValue()); 
  }
  for(T pred : Iterator2Iterable.make(G.getPredNodes(n))) {
   if (!fullColor && (!colors.containsKey(n) || !colors.containsKey(pred)) ) {
    continue;
   }
   Assert.assertTrue(n + " and pred: " + pred + " have same color:" + colors.get(n).intValue(), colors.get(n).intValue() != colors.get(pred).intValue()); 
  }
 }
}

代码示例来源:origin: wala/WALA

private void shortCircuitUnaryMeets(Graph<T> G, ITransferFunctionProvider<T,V> functions, UnionFind uf) {
 for (T node : G) {
  assert node != null;
  int nPred = G.getPredNodeCount(node);
  if (nPred == 1) {
   // short circuit by setting IN = OUT_p
   Object p = G.getPredNodes(node).next();
   // if (p == null) {
   // p = G.getPredNodes(node).next();
   // }
   assert p != null;
   uf.union(getIn(node), functions.hasEdgeTransferFunctions() ? getEdge(p, node) : getOut(p));
  }
 }
}

代码示例来源:origin: wala/WALA

private void shortCircuitUnaryMeets(Graph<T> G, ITransferFunctionProvider<T,V> functions, UnionFind uf) {
 for (T node : G) {
  assert node != null;
  int nPred = G.getPredNodeCount(node);
  if (nPred == 1) {
   // short circuit by setting IN = OUT_p
   Object p = G.getPredNodes(node).next();
   // if (p == null) {
   // p = G.getPredNodes(node).next();
   // }
   assert p != null;
   uf.union(getIn(node), functions.hasEdgeTransferFunctions() ? getEdge(p, node) : getOut(p));
  }
 }
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.util

private void shortCircuitUnaryMeets(Graph<T> G, ITransferFunctionProvider<T,V> functions, UnionFind uf) {
 for (T node : G) {
  assert node != null;
  int nPred = G.getPredNodeCount(node);
  if (nPred == 1) {
   // short circuit by setting IN = OUT_p
   Object p = G.getPredNodes(node).next();
   // if (p == null) {
   // p = G.getPredNodes(node).next();
   // }
   assert p != null;
   uf.union(getIn(node), functions.hasEdgeTransferFunctions() ? getEdge(p, node) : getOut(p));
  }
 }
}

代码示例来源:origin: wala/WALA

private static <T> void checkEdgeCounts(Graph<T> G) throws UnsoundGraphException {
 for (T N : G) {
  int count1 = G.getSuccNodeCount(N);
  int count2 = IteratorUtil.count(G.getSuccNodes(N));
  if (count1 != count2) {
   throw new UnsoundGraphException("getSuccNodeCount " + count1 + " is wrong for node " + N);
  }
  int count3 = G.getPredNodeCount(N);
  int count4 = IteratorUtil.count(G.getPredNodes(N));
  if (count3 != count4) {
   throw new UnsoundGraphException("getPredNodeCount " + count1 + " is wrong for node " + N);
  }
 }
}

代码示例来源:origin: wala/WALA

private static <T> void checkEdgeCounts(Graph<T> G) throws UnsoundGraphException {
 for (T N : G) {
  int count1 = G.getSuccNodeCount(N);
  int count2 = IteratorUtil.count(G.getSuccNodes(N));
  if (count1 != count2) {
   throw new UnsoundGraphException("getSuccNodeCount " + count1 + " is wrong for node " + N);
  }
  int count3 = G.getPredNodeCount(N);
  int count4 = IteratorUtil.count(G.getPredNodes(N));
  if (count3 != count4) {
   throw new UnsoundGraphException("getPredNodeCount " + count1 + " is wrong for node " + N);
  }
 }
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.util

private static <T> void checkEdgeCounts(Graph<T> G) throws UnsoundGraphException {
 for (T N : G) {
  int count1 = G.getSuccNodeCount(N);
  int count2 = IteratorUtil.count(G.getSuccNodes(N));
  if (count1 != count2) {
   throw new UnsoundGraphException("getSuccNodeCount " + count1 + " is wrong for node " + N);
  }
  int count3 = G.getPredNodeCount(N);
  int count4 = IteratorUtil.count(G.getPredNodes(N));
  if (count3 != count4) {
   throw new UnsoundGraphException("getPredNodeCount " + count1 + " is wrong for node " + N);
  }
 }
}

相关文章