本文整理汇总了Java中edu.uci.ics.jung.graph.DirectedGraph.getVertexCount方法的典型用法代码示例。如果您正苦于以下问题:Java DirectedGraph.getVertexCount方法的具体用法?Java DirectedGraph.getVertexCount怎么用?Java DirectedGraph.getVertexCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.DirectedGraph
的用法示例。
在下文中一共展示了DirectedGraph.getVertexCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCounts
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
/**
* Returns an array whose ith element (for i in [1,16]) is the number of
* occurrences of the corresponding triad type in <code>g</code>.
* (The 0th element is not meaningful; this array is effectively 1-based.)
*
* @param g
*/
public static <V,E> long[] getCounts(DirectedGraph<V,E> g) {
long[] count = new long[MAX_TRIADS];
List<V> id = new ArrayList<V>(g.getVertices());
// apply algorithm to each edge, one at at time
for (int i_v = 0; i_v < g.getVertexCount(); i_v++) {
V v = id.get(i_v);
for(V u : g.getNeighbors(v)) {
int triType = -1;
if (id.indexOf(u) <= i_v)
continue;
Set<V> neighbors = new HashSet<V>(CollectionUtils.union(g.getNeighbors(u), g.getNeighbors(v)));
neighbors.remove(u);
neighbors.remove(v);
if (g.isSuccessor(v,u) && g.isSuccessor(u,v)) {
triType = 3;
} else {
triType = 2;
}
count[triType] += g.getVertexCount() - neighbors.size() - 2;
for (V w : neighbors) {
if (shouldCount(g, id, u, v, w)) {
count [ triType ( triCode(g, u, v, w) ) ] ++;
}
}
}
}
int sum = 0;
for (int i = 2; i <= 16; i++) {
sum += count[i];
}
int n = g.getVertexCount();
count[1] = n * (n-1) * (n-2) / 6 - sum;
return count;
}
示例2: MarkovCentrality
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
public MarkovCentrality(DirectedGraph<V,E> graph, Set<V> rootNodes, Map<E,Number> edgeWeightKey) {
super.initialize(graph, true, false);
setPriors(rootNodes);
if (edgeWeightKey == null)
assignDefaultEdgeTransitionWeights();
else
setEdgeWeights(edgeWeightKey);
normalizeEdgeTransitionWeights();
mIndexer = Indexer.<V>create(graph.getVertices());
mRankings = new SparseDoubleMatrix1D(graph.getVertexCount());
}
示例3: actionPerformed
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
@Override
public void actionPerformed( ActionEvent e ) {
GraphCondensePanel gcp = new GraphCondensePanel( gps );
String options[] = { "OK", "Cancel" };
int opt = JOptionPane.showOptionDialog( null, gcp, "Condense Graph",
JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, options,
options[0] );
if ( 0 == opt ) {
int[] nodecount = new int[1];
ProgressTask pt = new ProgressTask( "Condensing Graph", new Runnable() {
@Override
public void run() {
DirectedGraph<SEMOSSVertex, SEMOSSEdge> oldg = gps.getVisibleGraph();
nodecount[0] = oldg.getVertexCount();
DirectedGraph<SEMOSSVertex, SEMOSSEdge> newg
= condense( oldg, gcp.getEdgeTypeToRemove(),
gcp.getEdgeEndpointType(), gcp.getPropertySource() );
GraphPlaySheet gps2 = new GraphPlaySheet( new GraphDataModel( newg ) );
gps2.setTitle( "Condensed Graph" );
gps.addSibling( gps2 );
nodecount[0] = newg.getVertexCount();
}
} ) {
@Override
public void done() {
super.done();
int count = gps.getVisibleGraph().getVertexCount() - nodecount[0];
String msg = "Graph condensed: " + count + " Nodes removed";
this.setLabel( msg );
JOptionPane.showMessageDialog( gps, msg, "Condenser Results",
JOptionPane.INFORMATION_MESSAGE );
}
};
OperationsProgress.getInstance( PlayPane.UIPROGRESS ).add( pt );
}
}
示例4: ParallelFloydWarshallJung
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
public ParallelFloydWarshallJung(DirectedGraph<V,E> graph, Transformer<? super E,? extends Number> edgeWeights,
Optional<FixedThreadPool> threadPool){
this.threadPool = threadPool;
this.graph = graph;
this.edgeWeights = edgeWeights;
int numNodes = graph.getVertexCount();
double[][] costs = new double[numNodes][numNodes];
Builder<Pair<V>,E> edgesUsedBuilder = ImmutableBiMap.builder();
{
Builder<V,Integer> nodeIndexBuilder = ImmutableBiMap.builder();
int i = 0;
for(V v: graph.getVertices()){
nodeIndexBuilder.put(v,i++);
}
this.nodeIndex = nodeIndexBuilder.build();
}
for(V source: nodeIndex.keySet()){
for(V sink : nodeIndex.keySet()){
Collection<E> edges = graph.findEdgeSet(source, sink);
double bestEdgeVal = Double.POSITIVE_INFINITY;
E bestEdge = null;
for(E edge: edges){
double newEdgeVal = edgeWeights.transform(edge).doubleValue();
if(newEdgeVal < bestEdgeVal){
bestEdgeVal = newEdgeVal;
bestEdge = edge;
}
}
if(bestEdge != null){
edgesUsedBuilder.put(new Pair<V>(source,sink),bestEdge);
costs[nodeIndex.get(source)][nodeIndex.get(sink)] = bestEdgeVal;
}
else{
costs[nodeIndex.get(source)][nodeIndex.get(sink)] = Double.POSITIVE_INFINITY;
}
}
}
this.edgesUsed = edgesUsedBuilder.build();
this.floydWarshall = new ParallelFloydWarshall(numNodes,costs,threadPool);
}