本文整理汇总了Java中edu.uci.ics.jung.graph.DirectedGraph.getVertices方法的典型用法代码示例。如果您正苦于以下问题:Java DirectedGraph.getVertices方法的具体用法?Java DirectedGraph.getVertices怎么用?Java DirectedGraph.getVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.DirectedGraph
的用法示例。
在下文中一共展示了DirectedGraph.getVertices方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEdge
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
/**
* Gets nodes that have both in- and out- edges and are of the given type
*
* @param graph the graph to inspect
* @param type the node type that has the edges
* @param endpoint
* @return
*/
public static MultiMap<SEMOSSVertex, CondenserTuple>
findNodesToCondense( DirectedGraph<SEMOSSVertex, SEMOSSEdge> graph,
URI type, URI endpoint ) {
MultiMap<SEMOSSVertex, CondenserTuple> removers = new MultiMap<>();
for ( SEMOSSVertex middle : graph.getVertices() ) {
if ( type.equals( middle.getType() ) ) {
SEMOSSEdge upstream = getEdge( endpoint, middle, graph, true );
SEMOSSEdge downstream = getEdge( endpoint, middle, graph, false );
// FIXME: we might have multiple pairs of
// endpoints through our middle, so loop
//while ( !( null == upstream || null == downstream ) ) {
if ( !( null == upstream || null == downstream ) ) {
removers.add( middle, new CondenserTuple( upstream, downstream ) );
}
// upstream = getVertex( endpoint, middle, graph, true );
//downstream = getVertex( endpoint, middle, graph, false );
//}
}
}
return removers;
}
示例2: findCircuits
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
public void findCircuits() throws JohnsonIllegalStateException {
blocked = new HashMap<Integer, Boolean>();
blockedNodes = new HashMap<Integer, List<Integer>>();
Stack<Integer> stack = new Stack<Integer>();
Integer s = 1;
while (s < dg.getVertexCount()) {
DirectedGraph<Integer, WeightedEdge> subGraph = subGraphFrom(s,dg);
DirectedGraph<Integer, WeightedEdge> leastScc = leastSCC(subGraph);
if (leastScc.getVertices().size() > 0) {
s = leastVertex(leastScc);
for (Integer i : leastScc.getVertices()) {
blocked.put(i, false);
blockedNodes.put(i, new ArrayList<Integer>());
}
boolean dummy = circuit(leastScc, s, s, stack);
s++;
}
else {
s = dg.getVertexCount();
}
}
}
示例3: ManageConstraintsPanel
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
/**
* Creates new form ManageConstraintsPanel
*
* @param engine
* @param graph
* @param ordering
*/
public ManageConstraintsPanel( IEngine engine,
DirectedGraph<QueryNode, QueryEdge> graph, List<QueryOrder> ordering ) {
this.engine = engine;
this.graph = graph;
List<QueryGraphElement> elements = new ArrayList<>( graph.getVertices() );
elements.addAll( graph.getEdges() );
model = new SparqlResultTableModel( elements, ordering );
filterRenderer = new FilterRenderer( model );
initComponents();
LabeledPairTableCellRenderer renderer
= LabeledPairTableCellRenderer.getUriPairRenderer();
Set<URI> labels = getAllProperties( elements );
renderer.cache( Utility.getInstanceLabels( labels, engine ) );
LabeledPairTableCellRenderer trenderer
= LabeledPairTableCellRenderer.getValuePairRenderer( engine );
trenderer.cache( Constants.ANYNODE, "<Any>" );
table.setFillsViewportHeight( true );
table.setDefaultRenderer( URI.class, renderer );
table.setDefaultRenderer( Value.class, trenderer );
table.getSelectionModel().addListSelectionListener( new ListSelectionListener() {
@Override
public void valueChanged( ListSelectionEvent e ) {
upbtn.setEnabled( !table.getSelectionModel().isSelectionEmpty() );
downbtn.setEnabled( !table.getSelectionModel().isSelectionEmpty() );
}
} );
}
示例4: rankGraph
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
private static Map<GraphNode, Double> rankGraph(
Set<GraphNode> nodes,
DirectedGraph<GraphNode, GraphEdge> jungInfo) {
KStepMarkov<GraphNode, GraphEdge> ranker =
new KStepMarkov<GraphNode, GraphEdge>(jungInfo, nodes, 6, null);
ranker.setRemoveRankScoresOnFinalize(false);
ranker.evaluate();
Map<GraphNode, Double> result = Maps.newHashMap();
for (GraphNode node : jungInfo.getVertices()) {
result.put(node, ranker.getVertexRankScore(node));
}
return result;
}
示例5: process
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
@Override
public String process(Map<DisambiguatedEntity, Integer> map, Paragraph p, Languages lang) {
Set<String> entitySet = new HashSet<String>();
List<String> entities = new LinkedList<String>();
for (Map.Entry<DisambiguatedEntity, Integer> entry : map.entrySet()) {
entities.add(entry.getKey().getEntityUri());
entitySet.add(entry.getKey().getEntityUri());
}
if (entities.size() == 0) {
return "";
} else {
computeWord2VecSimilarities(entitySet);
DirectedGraph<Vertex, Edge> graph = buildGraph(entities);
PageRank<Vertex, Edge> pr = new PageRank<Vertex, Edge>(graph,
MapTransformer.getInstance(edgeWeights), 0.1);
pr.setMaxIterations(100);
pr.evaluate();
Collection<Vertex> vertexCol = graph.getVertices();
String topEntity = null;
double max = 0;
for (Vertex v : vertexCol) {
Double score = pr.getVertexScore(v);
if (score > max) {
topEntity = v.getUris().get(0);
max = score;
}
}
return topEntity;
}
}
示例6: 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;
}
示例7: WeightedNIPaths
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
/**
* Constructs and initializes the algorithm.
* @param graph the graph whose nodes are being measured for their importance
* @param alpha the path decay coefficient (>= 1); 2 is recommended
* @param maxDepth the maximal depth to search out from the root set
* @param priors the root set (starting vertices)
*/
public WeightedNIPaths(DirectedGraph<V,E> graph, Factory<V> vertexFactory,
Factory<E> edgeFactory, double alpha, int maxDepth, Set<V> priors) {
super.initialize(graph, true,false);
this.vertexFactory = vertexFactory;
this.edgeFactory = edgeFactory;
mAlpha = alpha;
mMaxDepth = maxDepth;
mPriors = priors;
for (V v : graph.getVertices()) {
super.setVertexRankScore(v, 0.0);
}
}
示例8: leastVertex
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
public Integer leastVertex(DirectedGraph<Integer, WeightedEdge> in) {
Integer result = Integer.MAX_VALUE;
for (Integer i : in.getVertices()) {
if (i < result) {
result = i;
}
};
return result;
}
示例9: subGraphFrom
import edu.uci.ics.jung.graph.DirectedGraph; //导入方法依赖的package包/类
public static DirectedGraph<Integer, WeightedEdge> subGraphFrom(Integer i, DirectedGraph<Integer, WeightedEdge> in) {
DirectedGraph<Integer, WeightedEdge> result = new DirectedSparseGraph<Integer, WeightedEdge>();
for (Integer from : in.getVertices()) {
if (from >= i) {
for (Integer to : in.getSuccessors(from)) {
if (to >= i) {
result.addEdge(in.findEdge(from, to), from, to);
}
}
}
}
return result;
}
示例10: 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);
}