当前位置: 首页>>代码示例>>Java>>正文


Java Graphs.getOppositeVertex方法代码示例

本文整理汇总了Java中org.jgrapht.Graphs.getOppositeVertex方法的典型用法代码示例。如果您正苦于以下问题:Java Graphs.getOppositeVertex方法的具体用法?Java Graphs.getOppositeVertex怎么用?Java Graphs.getOppositeVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jgrapht.Graphs的用法示例。


在下文中一共展示了Graphs.getOppositeVertex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPath

import org.jgrapht.Graphs; //导入方法依赖的package包/类
@Override
public RoutingPath getPath(Device from, Device to) {
	List<Channel> path = DijkstraShortestPath.findPathBetween(
			getGraph(), from, to);
	if (path == null) {
		return null;
	}

	List<Device> nodes = new ArrayList<Device>();
	Device v = from;
	nodes.add(from);
	for (Channel e : path) {
		v = Graphs.getOppositeVertex(getGraph(), e, v);
		nodes.add(v);
	}

	return new RoutingPath(nodes, path);
}
 
开发者ID:flyroom,项目名称:PeerfactSimKOM_Clone,代码行数:19,代码来源:StarNetwork.java

示例2: getPath

import org.jgrapht.Graphs; //导入方法依赖的package包/类
@Override
public RoutingPath getPath(Device from, Device to) {
	List<Channel> path = DijkstraShortestPath.findPathBetween(getGraph(),
			from, to);
	if (path == null) {
		return null;
	}

	List<Device> nodes = new ArrayList<Device>();
	Device v = from;
	nodes.add(from);
	for (Channel e : path) {
		v = Graphs.getOppositeVertex(getGraph(), e, v);
		nodes.add(v);
	}
	return new RoutingPath(nodes, path);
}
 
开发者ID:flyroom,项目名称:PeerfactSimKOM_Clone,代码行数:18,代码来源:RandomNetwork.java

示例3: getSubGraph

import org.jgrapht.Graphs; //导入方法依赖的package包/类
/**
 * Extract a subgraph limited to the provided set of glyphs.
 *
 * @param set        the provided set of glyphs
 * @param graph      the global graph to extract from
 * @param checkEdges true if glyph edges may point outside the provided set.
 * @return the graph limited to glyph set and related edges
 */
public static SimpleGraph<Glyph, GlyphLink> getSubGraph (Set<Glyph> set,
                                                         SimpleGraph<Glyph, GlyphLink> graph,
                                                         boolean checkEdges)
{
    // Which edges should be extracted for this set?
    Set<GlyphLink> setEdges = new LinkedHashSet<GlyphLink>();

    for (Glyph glyph : set) {
        Set<GlyphLink> glyphEdges = graph.edgesOf(glyph);

        if (!checkEdges) {
            setEdges.addAll(glyphEdges); // Take all edges
        } else {
            // Keep only the edges that link within the set
            for (GlyphLink link : glyphEdges) {
                Glyph opposite = Graphs.getOppositeVertex(graph, link, glyph);

                if (set.contains(opposite)) {
                    setEdges.add(link);
                }
            }
        }
    }

    SimpleGraph<Glyph, GlyphLink> subGraph = new SimpleGraph<Glyph, GlyphLink>(GlyphLink.class);
    Graphs.addAllVertices(subGraph, set);
    Graphs.addAllEdges(subGraph, graph, setEdges);

    return subGraph;
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:39,代码来源:GlyphCluster.java

示例4: buildAdjacencyMatrix

import org.jgrapht.Graphs; //导入方法依赖的package包/类
protected INDArray buildAdjacencyMatrix(Graph<V, E> graph, Map<V, Integer> index) {
    final double[][] matrix = new double[graph.vertexSet().size()][graph.vertexSet().size()];

    for (Map.Entry<V, Integer> entry : index.entrySet()) {
        for (final E edge : graph.edgesOf(entry.getKey())) {
            final V neighbor = Graphs.getOppositeVertex(graph, edge, entry.getKey());
            matrix[entry.getValue()][index.get(neighbor)] = graph.getEdgeWeight(edge);
        }
    }

    for (int r = 0; r < matrix.length; r++) matrix[r][r] = 1;

    return Nd4j.create(matrix);
}
 
开发者ID:nlpub,项目名称:watset-java,代码行数:15,代码来源:MarkovClustering.java

示例5: getPrioritySubset

import org.jgrapht.Graphs; //导入方法依赖的package包/类
/**
 * Returns a List with unique elements, 
 * @param v1 vertex from g1
 * @return
 */
public List<V> getPrioritySubset(V v1){
	//The resulting list
	List<V> result = new ArrayList<V>();
	
	//list of already mapped vertices that neighbour v1
	List<V> v1Others = new ArrayList<V>();
	
	V v1other;
	V v2other;
	for(E e1 : g1.edgesOf(v1)){
		v1other = Graphs.getOppositeVertex(g1, e1, v1);
		if(mappedVerticesFromG1.contains(v1other)){
			v1Others.add(v1other);
		}
	}
	for(V v2 : g2.vertexSet()){
		//if v2's label is the same of v1's label and v2 has not been mapped yet
		if(v1.getLabel().equals(v2.getLabel()) && !mappedVerticesFromG2.contains(v2)){
			//test if there is an edge to a vertex which has already been mapped
			for(E e2 : g2.edgesOf(v2)){
				v2other = Graphs.getOppositeVertex(g2, e2, v2);
				//if the vertex v2other has already been mapped
				if(mappedVerticesFromG2.contains(v2other)){
					//labels are not checked, this is done at a later stage anyway and doing it twice is not needed and takes too much time
					result.add(v2);
					break;
				}
			}
		}
	}
	return result;
}
 
开发者ID:WellingR,项目名称:Maximal-Common-Subgraph,代码行数:38,代码来源:Marcs.java

示例6: createEdgeList

import org.jgrapht.Graphs; //导入方法依赖的package包/类
private void createEdgeList(SimpleDirectedWeightedGraph<Object,IntraDomainEdge> graph, ClosestFirstIteratorModified<Object,IntraDomainEdge> iter, Object startVertex, Object endVertex)
{
    List<IntraDomainEdge> edgeList = new ArrayList<IntraDomainEdge>();
    Object v = endVertex;

    while (true) {
    	IntraDomainEdge edge = iter.getSpanningTreeEdge(v);

        if (edge == null) {
            break;
        }
        
        edgeList.add(edge);
        v = Graphs.getOppositeVertex(graph, edge, v);
      
    }

    Collections.reverse(edgeList);
    double pathLength = iter.getShortestPathLength(endVertex);
    path =
        new GraphPathImpl<Object,IntraDomainEdge>(
            graph,
            startVertex,
            endVertex,
            edgeList,
            pathLength);
}
 
开发者ID:telefonicaid,项目名称:netphony-pce,代码行数:28,代码来源:ModifiedDijkstraSP.java

示例7: addUnseenChildrenOf

import org.jgrapht.Graphs; //导入方法依赖的package包/类
private void addUnseenChildrenOf(V vertex)
{
    for (E edge : specifics.edgesOf(vertex)) {
        if (nListeners != 0) {
            fireEdgeTraversed(createEdgeTraversalEvent(edge));
        }
        V oppositeV = Graphs.getOppositeVertex(graph, edge, vertex);

        if (isSeenVertex(oppositeV)) {
            encounterVertexAgain(oppositeV, edge);
        } else {
            encounterVertex(oppositeV, edge);
        }
    }
}
 
开发者ID:telefonicaid,项目名称:netphony-pce,代码行数:16,代码来源:CrossComponentIteratorModified.java

示例8: calculatePathLength

import org.jgrapht.Graphs; //导入方法依赖的package包/类
/**
 * Determine path length to a vertex via an edge, using the path length for
 * the opposite vertex.
 *
 * @param vertex the vertex for which to calculate the path length.
 * @param edge the edge via which the path is being extended.
 *
 * @return calculated path length.
 */
private double calculatePathLength(V vertex, E edge)
{
    assertNonNegativeEdge(edge);
 
    V otherVertex = Graphs.getOppositeVertex(getGraph(), edge, vertex);
    FibonacciHeapNode<QueueEntry<V, E>> otherEntry =
        getSeenData(otherVertex);
 
    return otherEntry.getKey()
        + getGraph().getEdgeWeight(edge);
}
 
开发者ID:telefonicaid,项目名称:netphony-pce,代码行数:21,代码来源:ClosestFirstIteratorModified.java

示例9: createEdgeList

import org.jgrapht.Graphs; //导入方法依赖的package包/类
private void createEdgeList(
    Graph<V, E> graph,
    ClosestFirstIterator<V, E> iter,
    V startVertex,
    V endVertex)
{
    List<E> edgeList = new ArrayList<E>();
 
    V v = endVertex;
 
    while (true) {
        E edge = iter.getSpanningTreeEdge(v);
 
        if (edge == null) {
            break;
        }
 
        edgeList.add(edge);
        v = Graphs.getOppositeVertex(graph, edge, v);
    }
 
    Collections.reverse(edgeList);
    double pathLength = iter.getShortestPathLength(endVertex);
    path =
        new GraphPathImpl<V, E>(
            graph,
            startVertex,
            endVertex,
            edgeList,
            pathLength);
}
 
开发者ID:telefonicaid,项目名称:netphony-pce,代码行数:32,代码来源:Dijkstra.java

示例10: getOppositeInter

import org.jgrapht.Graphs; //导入方法依赖的package包/类
/**
 * Report the opposite inter across the given relation of the provided inter
 *
 * @param inter    one side of the relation
 * @param relation the relation to cross
 * @return the vertex at the opposite side of the relation
 */
public Inter getOppositeInter (Inter inter,
                               Relation relation)
{
    return Graphs.getOppositeVertex(this, relation, inter);
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:13,代码来源:SIGraph.java


注:本文中的org.jgrapht.Graphs.getOppositeVertex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。