當前位置: 首頁>>代碼示例>>Java>>正文


Java Pair類代碼示例

本文整理匯總了Java中edu.uci.ics.jung.graph.util.Pair的典型用法代碼示例。如果您正苦於以下問題:Java Pair類的具體用法?Java Pair怎麽用?Java Pair使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pair類屬於edu.uci.ics.jung.graph.util包,在下文中一共展示了Pair類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addVertex

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
@Override
public boolean addVertex(V vertex) {
    if(vertex == null) {
        throw new IllegalArgumentException("vertex may not be null");
    }
    if (!containsVertex(vertex)) 
    {
        vertices.put(vertex, new Pair<Set<E>>(new TreeSet<E>(edge_comparator), 
            new TreeSet<E>(edge_comparator)));
        return true;
    } 
    else 
    {
    	return false;
    }
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:17,代碼來源:SortedSparseMultigraph.java

示例2: f

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
Collection<VirtualNode> f(Set<VirtualNode> vns, VirtualNetwork g) {
	Collection<VirtualNode> result = new LinkedList<VirtualNode>();

	for (VirtualLink vl : g.getEdges()) {
		Pair<VirtualNode> endpoints = g.getEndpoints(vl);
		VirtualNode n_i = endpoints.getFirst();
		VirtualNode n_j = endpoints.getSecond();
		if (Utils.contains(n_j, vns)) {
			if (!Utils.contains(n_i, vns)) {
				if (!Utils.contains(n_i, result)) {
					result.add(n_i);
				}
			}
		} else {
			if (Utils.contains(n_i, vns)) {
				if (!Utils.contains(n_j, result)) {
					result.add(n_j);
				}
			}
		}
	}

	return result;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:25,代碼來源:SubgraphIsomorphismAlgorithm.java

示例3: findBiggestLinkStress

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
double findBiggestLinkStress(SubstrateNetwork sNetwork,
		Collection<SubstrateLink> links) {
	double maxNumber = 0.0, tmp = 0.0;
	SubstrateLink maxLink = null;

	for (SubstrateLink sl : links) {
		Pair<SubstrateNode> endpoints = sNetwork.getEndpoints(sl);

		if (maxLink == null
				| (tmp = getStressLevel(sNetwork, endpoints.getFirst(), sl)) > maxNumber) {
			maxNumber = tmp;
			maxLink = sl;
		}
		if (maxLink == null
				| (tmp = getStressLevel(sNetwork, endpoints.getSecond(), sl)) > maxNumber) {
			maxNumber = tmp;
			maxLink = sl;
		}
	}

	return maxNumber;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:23,代碼來源:BasicVNAssignmentAlgorithm.java

示例4: occupyPathResources

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
public static LinkedList<ResourceDemandEntry> occupyPathResources(
		List<AbstractDemand> demands, List<AbstractDemand> hiddenhopDemands,
		List<SubstrateLink> path, SubstrateNetwork sNetwork) {
	
	LinkedList<ResourceDemandEntry> resources =
			new LinkedList<ResourceDemandEntry>();

		int i = 1;
		for (SubstrateLink e : path) {
			resources.addAll(occupyResources(demands, e.get()));

			if (i != path.size()) {
				Pair<SubstrateNode> endpoints = sNetwork.getEndpoints(e);
				Collection<ResourceDemandEntry> entry =
					occupyHiddenHop(endpoints.getSecond(), hiddenhopDemands);
				resources.addAll(entry);
			}
			++i;
		}
		
		return resources;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:23,代碼來源:Utils.java

示例5: transform

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
@Override
public Shape transform(Context<Graph<V, E>, E> context) {

	// --- Get the shape for this edge, returning either the --------------
	// --- shared instance or, in the case of self-loop edges, the --------
	// --- SimpleLoop shared instance.
	
	Graph<V,E> graph = context.graph;
   	E e = context.element;
       
       Pair<V> endpoints = graph.getEndpoints(e);
       if(endpoints != null) {
       	boolean isLoop = endpoints.getFirst().equals(endpoints.getSecond());
       	if (isLoop) {
       		return this.getLoop().transform(context);
       	}
       }
       // --- Return the edge shape ------------------------------------------
       if (e instanceof GraphEdge) {
       	return this.getGeneralPath((GraphEdge)e);
       } else {
       	return this.getLine();
       }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:25,代碼來源:EdgeShapePolyline.java

示例6: transform

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
public Paint transform( Exit exit ) {
    Layout<Room, Exit> layout = vv.getGraphLayout();
    Pair<Room> pair = layout.getGraph().getEndpoints( exit );
    Room begin = pair.getFirst();
    Room end = pair.getSecond();
    Point2D beginPoint = transformer.transform( layout.transform( begin ) );
    Point2D endPoint = transformer.transform( layout.transform( end ) );
    float xFirst = (float) beginPoint.getX();
    float yFirst = (float) beginPoint.getY();
    float xEnd = (float) endPoint.getX();
    float yEnd = (float) endPoint.getY();

    if (selfLoop.evaluate( Context.<Graph<Room, Exit>, Exit>getInstance( layout.getGraph(), exit ) )) {
        xEnd += 50;
        yEnd += 50;
    }

    return new GradientPaint( xFirst, yFirst, getColorFor( begin ), xEnd, yEnd, getColorFor( end ), true );
}
 
開發者ID:lauriholmas,項目名稱:batmapper,代碼行數:20,代碼來源:ExitPaintTransformer.java

示例7: main

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
public static void main(String[] args) {
	// create FNSS topology
	Topology topology = new Topology();
	topology.addEdge("1", "2", new Edge());
	topology.addEdge("2", "3", new Edge());
	
	// convert to JGraphT
	Graph<String, Edge> graph = JUNGConverter.getGraph(topology);
	
	// Find shortest paths
	String source = "3";
	String destination = "1";
	DijkstraShortestPath<String, Edge> shortestPath = 
			new DijkstraShortestPath<String, Edge>(graph);
	List<Edge> path = shortestPath.getPath(source, destination);

	// Print results
	System.out.println("Shortest path from " + source + " to " + destination + ":");
	for (Edge e : path) {
		Pair<String> endpoints = graph.getEndpoints(e);
		System.out.println(endpoints.getFirst() + " -> " + endpoints.getSecond());
	}
}
 
開發者ID:fnss,項目名稱:fnss-java,代碼行數:24,代碼來源:ExampleJUNG.java

示例8: printEdge

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
/**
 * private method to print an edge in the file
 * @param edge
 */
private void printEdge(Edge edge)
{

	if (network.getEdgeType(edge) == EdgeType.DIRECTED)
		ps.print("edge: ("+ network.getSource(edge).getId() +","+ network.getDest(edge).getId()+")");
	else
	{
		Pair<Vertex> endpoints = network.getEndpoints(edge);
		ps.print("edge: ("+ endpoints.getFirst().getId() +","+ endpoints.getSecond().getId()+")");	
	}
	if (edge.getLabel() != null)
		ps.print(" label{"+edge.getLabel()+"}");
	ps.print(" weight{"+edge.getWeight()+"}");
	ps.print(" width{"+edge.getWidth()+"}");
	if (edge.getColor() != null)
		ps.print(" color{"+((double)edge.getColor().getRed()/256.d)
				+","+((double)edge.getColor().getGreen()/256.d)+","+((double)edge.getColor().getBlue()/256.d)+"}");
	if (edge.getVar1() != null)
		ps.print(" var1{"+edge.getVar1()+"}");
	if (edge.getVar2() != null)
		ps.print(" var2{"+edge.getVar2()+"}");
	if (edge.isExcluded())
		ps.print(" hide");
	ps.print("\n");
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:30,代碼來源:CxfSaver.java

示例9: addSourceSubtreeRootedAt

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
private void addSourceSubtreeRootedAt(Node n, Tree.Node tn, int firstIndex, int lastIndex,
    String[] sourceWords) {
  int nextUncoveredIndex = firstIndex;
  Tree.NodeSourceStartComparator cmp = new Tree.NodeSourceStartComparator();
  List<Tree.Node> children = tn.children();
  Collections.sort(children, cmp);
  for (Tree.Node child : children) {
    if (child.isLeaf()) {
      continue;
    }
    int sourceStartIndex = child.sourceStartIndex();
    int sourceEndIndex = child.sourceEndIndex();
    if (sourceStartIndex > nextUncoveredIndex) {
      insertSourceLeaf(n, sourceWords, nextUncoveredIndex, sourceStartIndex);
    }
    Node childNode = new Node(child.label(), true);
    addEdge(new DerivationTreeEdge(true), new Pair<>(n, childNode), EdgeType.DIRECTED);
    nextUncoveredIndex = sourceEndIndex;
    addSourceSubtreeRootedAt(childNode, child, sourceStartIndex, sourceEndIndex, sourceWords);
  }
  if (nextUncoveredIndex < lastIndex) {
    insertSourceLeaf(n, sourceWords, nextUncoveredIndex, lastIndex);
  }
}
 
開發者ID:apache,項目名稱:incubator-joshua,代碼行數:25,代碼來源:DerivationTree.java

示例10: readJUNGGraph

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
public static <V, E> Network readJUNGGraph(DirectedOrderedSparseMultigraph<V, E> graph, int modularityFunction) {
    StringBuilder stringBuilder = new StringBuilder();
    ArrayList<Object> vertices = new ArrayList<>(graph.getVertices());
    for (E edge : graph.getEdges()) {
        Pair<V> endpoints = graph.getEndpoints(edge);
        int firstVertex = vertices.indexOf(endpoints.getFirst());
        int secondVertex = vertices.indexOf(endpoints.getSecond());
        int smallerVertex, largerVertex;

        if (firstVertex > secondVertex) {
            smallerVertex = secondVertex;
            largerVertex = firstVertex;
        } else {
            smallerVertex = firstVertex;
            largerVertex = secondVertex;
        }
        stringBuilder.append(smallerVertex).append("\t").append(largerVertex).append("\n");
    }
    return readInputString(stringBuilder.toString(), modularityFunction);
}
 
開發者ID:deepminder,項目名稱:SLM4J,代碼行數:21,代碼來源:ModularityOptimizer.java

示例11: getEdgeScore

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
public Double getEdgeScore(E e) {
	Double score = scoreMap.get(e);
	if (score != null) return score;
	Pair<V> ends = g.getEndpoints(e);
	Set<V> vmap = new HashSet<V>(g.getNeighbors(ends.getFirst()));
	vmap.add(ends.getFirst());
	Collection<V> v1Neighbors = g.getNeighbors(ends.getSecond());
	int countCommon = 0;
	if (vmap.contains(ends.getSecond())){
		countCommon++;
	}
	for (V neighbor : v1Neighbors){
		if (vmap.contains(neighbor)){
			countCommon++;
		}
	}
	Double structureSimilarity = 
		(double)countCommon/Math.sqrt(vmap.size()*(v1Neighbors.size()+1));
	scoreMap.put(e, structureSimilarity);
	return structureSimilarity;
}
 
開發者ID:MKLab-ITI,項目名稱:mgraph-summarization,代碼行數:22,代碼來源:StructuralSimilarityScorer.java

示例12: toDirected

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
public static <V> DirectedGraph<V, WeightedEdge> toDirected(Graph<V, WeightedEdge> graph) {	
	DirectedGraph<V, WeightedEdge> directedGraph = new DirectedSparseGraph<V, WeightedEdge>();

	// Add all vertices first
	Collection<V> vertices = graph.getVertices();
	for(V vertex : vertices) {
		directedGraph.addVertex(vertex);
	}
	
	// Add directed edges
	for(WeightedEdge edge : graph.getEdges()) {	
		Pair<V> endpoints = graph.getEndpoints(edge);
		directedGraph.addEdge(new WeightedEdge(edge.getWeight()), endpoints.getFirst(), endpoints.getSecond());
		directedGraph.addEdge(new WeightedEdge(edge.getWeight()), endpoints.getSecond(), endpoints.getFirst());
	}
	return directedGraph;
}
 
開發者ID:MKLab-ITI,項目名稱:mgraph-summarization,代碼行數:18,代碼來源:GraphUtils.java

示例13: getShortestPath

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
public List<E> getShortestPath(V source, V sink){
	List<Integer> nodes = this.floydWarshall.shortestPath(this.nodeIndex.get(source), this.nodeIndex.get(sink));
	if(nodes == null){
		return null;
	}
	else if(nodes.size() > 1){
		List<E> ans = new ArrayList<E>();
		for(int i = 1; i < nodes.size(); i++){
			ans.add(this.edgesUsed.get(new Pair<V>(this.nodeIndex.inverse().get(nodes.get(i-1)), this.nodeIndex.inverse().get(nodes.get(i)))));
		}
		return ans;
	}
	else{
		throw new RuntimeException();
	}
}
 
開發者ID:rma350,項目名稱:kidneyExchange,代碼行數:17,代碼來源:ParallelFloydWarshallJung.java

示例14: loadGraphml

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
@Override
public void loadGraphml() throws Exception {
    final G graph = factory.create();
    MyGraphMLReader gmlr = loadGraphmlInGraph(urlPath, graph);
    Collection<String> verteces = graph.getVertices();
    for (String vertex :verteces){
        if(!entireGraph.containsVertex(vertex)){
            entireGraph.addVertex(vertex);
        }
    }
    Collection<String> edges = graph.getEdges();
    for (String edge : edges){
        Pair<String> endpoints = graph.getEndpoints(edge);
        if (!entireGraph.containsEdge(edge)){
            entireGraph.addEdge(edge,endpoints);
        }
    }
    graphMetadatas = gmlr.getGraphMetadata();
    edgeMetadatas = gmlr.getEdgeMetadata();
    vertexMetadatas = gmlr.getVertexMetadata();
    notifyListeners(gmlr.getVertexMetadata(), gmlr.getEdgeMetadata(), graph);
}
 
開發者ID:iTransformers,項目名稱:netTransformer,代碼行數:23,代碼來源:FileSystemGraphmlLoader.java

示例15: f

import edu.uci.ics.jung.graph.util.Pair; //導入依賴的package包/類
Collection<VirtualNode> f(Set<VirtualNode> vns, VirtualNetwork g) {
    Collection<VirtualNode> result = new LinkedList<VirtualNode>();

    for (VirtualLink vl : g.getEdges()) {
        Pair<VirtualNode> endpoints = g.getEndpoints(vl);
        VirtualNode n_i = endpoints.getFirst();
        VirtualNode n_j = endpoints.getSecond();
        if (Utils.contains(n_j, vns)) {
            if (!Utils.contains(n_i, vns)) {
                if (!Utils.contains(n_i, result)) {
                    result.add(n_i);
                }
            }
        } else {
            if (Utils.contains(n_i, vns)) {
                if (!Utils.contains(n_j, result)) {
                    result.add(n_j);
                }
            }
        }
    }

    return result;
}
 
開發者ID:liruixpc11,項目名稱:crucian,代碼行數:25,代碼來源:SubgraphIsomorphismAlgorithm.java


注:本文中的edu.uci.ics.jung.graph.util.Pair類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。