edu.uci.ics.jung.graph.Graph.degree()方法的使用及代码示例

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

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

Graph.degree介绍

暂无

代码示例

代码示例来源:origin: geogebra/geogebra

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
 */
@Override
public int degree(V vertex) {
  return delegate.degree(vertex);
}

代码示例来源:origin: geogebra/geogebra

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
 */
@Override
public int degree(V vertex) {
  return delegate.degree(vertex);
}

代码示例来源:origin: net.sf.jung/jung-samples

public boolean apply(Context<Graph<V,E>,V> context) {
      Graph<V,E> graph = context.graph;
      V v = context.element;
//            Vertex v = (Vertex)arg0;
      if (filter_small)
        return (graph.degree(v) >= MIN_DEGREE);
      else
        return true;
    }
  }

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-comanalyzer

/**
 * Returns the degree (number of incident edges) of a vertex.
 * @param vertex The vertex.
 * @return The degree.
 */
public int degree(Object vertex)
{
  return delegate.degree(vertex);
}

代码示例来源:origin: net.sf.jung/jung-api

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
 */
public int degree(V vertex) {
  return delegate.degree(vertex);
}

代码示例来源:origin: geogebra/geogebra

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
 */
@Override
public synchronized int degree(V vertex) {
  return delegate.degree(vertex);
}

代码示例来源:origin: net.sf.jung/jung-api

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
 */
public int degree(V vertex) {
  return delegate.degree(vertex);
}

代码示例来源:origin: net.sf.jung/jung-api

/**
 * @see edu.uci.ics.jung.graph.Hypergraph#degree(java.lang.Object)
 */
public synchronized int degree(V vertex) {
  return delegate.degree(vertex);
}

代码示例来源:origin: net.sf.jung/jung-visualization

public int degree(V vertex) {
  return graph.degree(vertex);
}
public E findEdge(V v1, V v2) {

代码示例来源:origin: geogebra/geogebra

/**
 * Returns the effective size of <code>v</code> divided by the number of
 * alters in <code>v</code>'s network. (In other words,
 * <code>effectiveSize(v) / v.degree()</code>.) If
 * <code>v.degree() == 0</code>, returns 0.
 */
public double efficiency(V v) {
  double degree = g.degree(v);
  if (degree == 0) {
    return 0;
  }
  return effectiveSize(v) / degree;
}

代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2

/**
 * Returns the effective size of <code>v</code> divided by the number of 
 * alters in <code>v</code>'s network.  (In other words, 
 * <code>effectiveSize(v) / v.degree()</code>.)
 * If <code>v.degree() == 0</code>, returns 0.
 */
public double efficiency(V v) {
  double degree = g.degree(v);
  
  if (degree == 0)
    return 0;
  else
    return effectiveSize(v) / degree;
}

代码示例来源:origin: net.sf.jung/jung-algorithms

/**
 * Returns the effective size of <code>v</code> divided by the number of 
 * alters in <code>v</code>'s network.  (In other words, 
 * <code>effectiveSize(v) / v.degree()</code>.)
 * If <code>v.degree() == 0</code>, returns 0.
 * 
 * @param v the vertex whose properties are being measured
 * @return the effective size of the vertex divided by its degree
 */
public double efficiency(V v) {
  double degree = g.degree(v);
  
  if (degree == 0)
    return 0;
  else
    return effectiveSize(v) / degree;
}

代码示例来源:origin: net.sf.jung/jung-samples

public Shape apply(V v)
  {
    if (funny_shapes)
    {
      if (graph.degree(v) < 5)
      {    
        int sides = Math.max(graph.degree(v), 3);
        return factory.getRegularPolygon(v, sides);
      }
      else
        return factory.getRegularStar(v, graph.degree(v));
    }
    else
      return factory.getEllipse(v);
  }
}

代码示例来源:origin: net.sf.jung/jung-algorithms

/**
 * Generates a graph whose degree distribution approximates a power-law.
 * @return the generated graph
 */
public Graph<V,E> get() {
  Graph<V,E> graph = initializeGraph();
  List<V> vertices = new ArrayList<V>(graph.getVertices());
  for (int rIdx = 0; rIdx < mNumIterations; rIdx++) {
    V v = null;
    int degree = 0;
    do {
      v = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
      degree = graph.degree(v);
    } while (degree == 0);
    List<E> edges = new ArrayList<E>(graph.getIncidentEdges(v));
    E randomExistingEdge = edges.get((int) (mRandom.nextDouble()*degree));
    // FIXME: look at email thread on a more efficient RNG for arbitrary distributions
    
    V x = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    V y = null;
    do {
      y = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    } while (mRandom.nextDouble() > ((graph.degree(y)+1)/mMaxDegree));
    if (!graph.isSuccessor(y,x) && x != y) {
      graph.removeEdge(randomExistingEdge);
      graph.addEdge(edgeFactory.get(), x, y);
    }
  }
  return graph;
}

代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2

/**
 * Generates a graph whose degree distribution approximates a power-law.
 * @return the generated graph
 */
public Graph<V,E> create() {
  Graph<V,E> graph = initializeGraph();
  List<V> vertices = new ArrayList<V>(graph.getVertices());
  for (int rIdx = 0; rIdx < mNumIterations; rIdx++) {
    V v = null;
    int degree = 0;
    do {
      v = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
      degree = graph.degree(v);
    } while (degree == 0);
    List<E> edges = new ArrayList<E>(graph.getIncidentEdges(v));
    E randomExistingEdge = edges.get((int) (mRandom.nextDouble()*degree));
    // FIXME: look at email thread on a more efficient RNG for arbitrary distributions
    
    V x = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    V y = null;
    do {
      y = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    } while (mRandom.nextDouble() > ((graph.degree(y)+1)/mMaxDegree));
    if (!graph.isSuccessor(y,x) && x != y) {
      graph.removeEdge(randomExistingEdge);
      graph.addEdge(edgeFactory.create(), x, y);
    }
  }
  return graph;
}

代码示例来源:origin: net.sf.jung/jung-algorithms

protected Graph<V,E> initializeGraph() {
  Graph<V,E> graph = null;
  graph = graphFactory.get();
  for(int i=0; i<mNumVertices; i++) {
    graph.addVertex(vertexFactory.get());
  }
  List<V> vertices = new ArrayList<V>(graph.getVertices());
  while (graph.getEdgeCount() < mNumEdges) {
    V u = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    V v = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    if (!graph.isSuccessor(v,u)) {
      graph.addEdge(edgeFactory.get(), u, v);
    }
  }
  double maxDegree = 0;
  for (V v : graph.getVertices()) {
    maxDegree = Math.max(graph.degree(v),maxDegree);
  }
  mMaxDegree = maxDegree; //(maxDegree+1)*(maxDegree)/2;
  return graph;
}

代码示例来源:origin: geogebra/geogebra

protected Graph<V, E> initializeGraph() {
  Graph<V, E> graph = null;
  graph = graphFactory.create();
  for (int i = 0; i < mNumVertices; i++) {
    graph.addVertex(vertexFactory.create());
  }
  List<V> vertices = new ArrayList<V>(graph.getVertices());
  while (graph.getEdgeCount() < mNumEdges) {
    V u = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    V v = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    if (!graph.isSuccessor(v, u)) {
      graph.addEdge(edgeFactory.create(), u, v);
    }
  }
  double maxDegree = 0;
  for (V v : graph.getVertices()) {
    maxDegree = Math.max(graph.degree(v), maxDegree);
  }
  mMaxDegree = maxDegree; // (maxDegree+1)*(maxDegree)/2;
  return graph;
}

代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2

protected Graph<V,E> initializeGraph() {
  Graph<V,E> graph = null;
  graph = graphFactory.create();
  for(int i=0; i<mNumVertices; i++) {
    graph.addVertex(vertexFactory.create());
  }
  List<V> vertices = new ArrayList<V>(graph.getVertices());
  while (graph.getEdgeCount() < mNumEdges) {
    V u = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    V v = vertices.get((int) (mRandom.nextDouble() * mNumVertices));
    if (!graph.isSuccessor(v,u)) {
      graph.addEdge(edgeFactory.create(), u, v);
    }
  }
  double maxDegree = 0;
  for (V v : graph.getVertices()) {
    maxDegree = Math.max(graph.degree(v),maxDegree);
  }
  mMaxDegree = maxDegree; //(maxDegree+1)*(maxDegree)/2;
  return graph;
}

代码示例来源:origin: org.opendaylight.controller.thirdparty/net.sf.jung2

/**
 * Burt's measure of the effective size of a vertex's network.  Essentially, the
 * number of neighbors minus the average degree of those in <code>v</code>'s neighbor set,
 * not counting ties to <code>v</code>.  Formally: 
 * <pre>
 * effectiveSize(v) = v.degree() - (sum_{u in N(v)} sum_{w in N(u), w !=u,v} p(v,w)*m(u,w))
 * </pre>
 * where 
 * <ul>
 * <li/><code>N(a) = a.getNeighbors()</code>
 * <li/><code>p(v,w) =</code> normalized mutual edge weight of v and w
 * <li/><code>m(u,w)</code> = maximum-scaled mutual edge weight of u and w
 * </ul>
 * @see #normalizedMutualEdgeWeight(Object, Object)
 * @see #maxScaledMutualEdgeWeight(Object, Object) 
 */
public double effectiveSize(V v)
{
  double result = g.degree(v);
  for(V u : g.getNeighbors(v)) {
    for(V w : g.getNeighbors(u)) {
      if (w != v && w != u)
        result -= normalizedMutualEdgeWeight(v,w) * 
             maxScaledMutualEdgeWeight(u,w);
    }
  }
  return result;
}

代码示例来源:origin: net.sf.jung/jung-samples

/**
 * @return the graph for this demo
 */
Graph<String,Number> getGraph() {
  Graph<String,Number> g =
    new EppsteinPowerLawGenerator<String,Number>(
        new GraphFactory(), new VertexFactory(), new EdgeFactory(), 26, 50, 50).get();
  Set<String> removeMe = new HashSet<String>();
  for (String v : g.getVertices()) {
    if ( g.degree(v) == 0 ) {
      removeMe.add( v );
    }
  }
  for(String v : removeMe) {
    g.removeVertex(v);
  }
  return g;
}

相关文章