com.ibm.wala.util.graph.Graph类的使用及代码示例

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

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

Graph介绍

[英]Basic interface for a directed graph. We choose to define a Graph as a composition of a NodeManager and an EdgeManager, which track nodes and edges, respectively. This way, in many cases we can compose separate NodeManager and EdgeManager implementations to create Graph implementations, using delegation.
[中]

代码示例

代码示例来源:origin: uber/NullAway

for (ISSABasicBlock succ : Iterator2Iterable.make(pdomTree.getSuccNodes(node))) {
 nodeQueue.add(succ);

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

@Override
public void addEdge(T src, T dst) throws IllegalArgumentException {
 delegate.addEdge(src, dst);
}

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

@Override
public void addNode(T n) {
 delegate.addNode(n);
}

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

public static <T> void copyInto(Graph<T> g, Graph<T> into) {
 if (g == null) {
  throw new IllegalArgumentException("g is null");
 }
 for (T name : g) {
  into.addNode(name);
 }
 for (T n : g) {
  for (T succ : Iterator2Iterable.make(g.getSuccNodes(n))) {
   into.addEdge(n, succ);
  }
 }
}

代码示例来源: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 Graph<String> createGraph(String edges) {
 Graph<String> g = SlowSparseNumberedGraph.make();
 for(int i = 0; i < edges.length(); i+= 2) {
  String from = edges.substring(i, i+1);
  if (! g.containsNode(from)) {
   g.addNode(from);
  }
  
  String to = edges.substring(i+1, i+2);
  if (! g.containsNode(to)) {
   g.addNode(to);
  }
  
  g.addEdge(from, to);
 }
 return g;
}

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

@Override
public Object[] getChildren(Object parentElement) {
 Object[] result = new Object[graph.getSuccNodeCount(parentElement)];
 int i = 0;
 for (Object o : Iterator2Iterable.make(graph.getSuccNodes(parentElement))) {
  result[i++] = o;
 }
 return result;
}

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

/**
 * @throws NullPointerException if G is null
 */
public SlowDFSFinishTimeIterator(Graph<T> G) throws NullPointerException {
 this(G, G == null ? null : G.iterator());
}

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

/**
 * @return a graph with the expected structure
 */
public static Graph<String> buildGraph() {
 Graph<String> G = SlowSparseNumberedGraph.make();
 for (int i = 0; i < nodeNames.length(); i++) {
  String n = nodeNames.substring(i, i + 1);
  G.addNode(n);
  nodes[i] = n;
 }
 G.addEdge(nodes[0], nodes[1]);
 G.addEdge(nodes[1], nodes[2]);
 G.addEdge(nodes[1], nodes[3]);
 G.addEdge(nodes[2], nodes[4]);
 G.addEdge(nodes[3], nodes[4]);
 G.addEdge(nodes[4], nodes[5]);
 return G;
}

代码示例来源: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

@Override
public int getNumberOfNodes() {
 return delegate.getNumberOfNodes();
}

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

@Override
public boolean hasExceptionalEdge(T src, T dst) {
 return !deleted.hasEdge(src, dst);
}

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

protected Pair<TaxoNode, TaxoNode> addEdge(T sub, T sup) {
  assert !sub.equals(sup) : sub+"\n"+sup;
  TaxoNode subN = addNode(sub);
  TaxoNode supN = addNode(sup);
  if (!lattice.hasEdge(subN, supN)) {
    lattice.addEdge(subN, supN);
  }
  return Pair.make(subN, supN);
}

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

@Override
public int getSuccNodeCount(T N) throws IllegalArgumentException {
 return delegate.getSuccNodeCount(N);
}

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

@Override
public boolean containsNode(T N) {
 return delegate.containsNode(N);
}

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

public static <T> void copyInto(Graph<T> g, Graph<T> into) {
 if (g == null) {
  throw new IllegalArgumentException("g is null");
 }
 for (T name : g) {
  into.addNode(name);
 }
 for (T n : g) {
  for (T succ : Iterator2Iterable.make(g.getSuccNodes(n))) {
   into.addEdge(n, succ);
  }
 }
}

代码示例来源: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

/**
 * Construct an enumeration across the SCCs of a given graph.
 * 
 * @param G
 *          The graph over which to construct SCCs
 * @throws NullPointerException  if G is null
 */
public SCCIterator(Graph<T> G) throws NullPointerException {
 this(G, G == null ? null : G.iterator());
}

代码示例来源: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 int getNumberOfNodes() {
 return delegate.getNumberOfNodes();
}

相关文章