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


Java EdgeType類代碼示例

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


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

示例1: testBfs

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
@Test
public void testBfs() throws Exception {

	DirectedGraph<URI, URI> graph = new DirectedSparseGraph<>();
	graph.addVertex( YURI );
	graph.addVertex( YUGO );
	graph.addEdge( YPY, YURI, YUGO, EdgeType.DIRECTED );

	Collection<URI> roots = Arrays.asList( YURI );
	GraphToTreeConverter.Search search = GraphToTreeConverter.Search.BFS;
	Forest<URI, URI> result = GraphToTreeConverter.convert( graph, roots, search );
	assertEquals( 1, result.getTrees().size() );

	Tree<URI, URI> tree = result.getTrees().iterator().next();
	assertEquals( YURI, tree.getRoot() );
	assertEquals( YUGO, tree.getChildren( YURI ).iterator().next() );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:18,代碼來源:GraphToTreeConverterTest.java

示例2: addEdge

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
protected void addEdge(int i, int j){
	List<Integer> aI, aJ;
	assocG.addEdge(numEdges, i,j,EdgeType.UNDIRECTED);
	numEdges++;
	if (adjList.containsKey(i)){
		aI = adjList.get(i);
	} else{
		aI = new ArrayList<Integer>();
		adjList.put(i, aI);
	}
	aI.add(j);
	if (adjList.containsKey(j)){
		aJ = adjList.get(j);
	} else {
		aJ = new ArrayList<Integer>();
		adjList.put(j, aJ);
	}
	aJ.add(i);
	return;
}
 
開發者ID:sriram0339,項目名稱:FixrAssociationRuleMining,代碼行數:21,代碼來源:AssociationRuleGraph.java

示例3: getUnreachabilitiyScenario

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
/**
 * @return There is only one shortest path! We have to prevent endless
 *         looping!
 */
public static KspTestScenario<String, MyLink> getUnreachabilitiyScenario() {
	Graph<String, MyLink> graph = new DirectedOrderedSparseMultigraph<String, MyLink>();

	String s = new String("S"); // the source
	graph.addVertex(s);
	String v = new String("V"); // the unreachable vertex!
	graph.addVertex(v);
	String w = new String("W"); // the intermediate vertex
	graph.addVertex(w);
	String t = new String("T"); // the target
	graph.addVertex(t);

	graph.addEdge(new MyLink(1, "S-V"), s, v, EdgeType.DIRECTED); // dead-end
	graph.addEdge(new MyLink(1, "S-W"), s, w, EdgeType.DIRECTED);
	graph.addEdge(new MyLink(1, "W-T"), w, t, EdgeType.DIRECTED);

	List<MyLink> path = new ArrayList<MyLink>();
	path.add(graph.findEdge(s, w));
	path.add(graph.findEdge(w, t));

	List<List<MyLink>> temp = new LinkedList<List<MyLink>>();
	temp.add(path);

	return new KspTestScenario<String, MyLink>(graph, temp, s, t);
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:30,代碼來源:KspTestScenarios.java

示例4: testUnreachable

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
@Test
public void testUnreachable() {
	Graph<String, MyLink> g = new DirectedOrderedSparseMultigraph<String, MyLink>();

	String n1 = new String("S"); // S
	g.addVertex(n1);
	String n2 = new String("A"); // A
	g.addVertex(n2);
	String n3 = new String("B"); // B -- not connected
	g.addVertex(n3);

	g.addEdge(new MyLink(1, "S-A"), n1, n2, EdgeType.DIRECTED); // S - A

	Transformer<MyLink, Number> weightTrans = new Transformer<MyLink, Number>() {
		@Override
		public Number transform(MyLink link) {
			return link.getWeight();
		}
	};
	SuurballeTarjan<String, MyLink> testMain = new SuurballeTarjan<String, MyLink>(
			g, weightTrans);
	assertEquals(null, testMain.getDisjointPaths(n1, n3));
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:24,代碼來源:SuurballeTarjanTest.java

示例5: testNoDisjointSolution

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
@Test
public void testNoDisjointSolution() {
	Graph<String, MyLink> g = new DirectedOrderedSparseMultigraph<String, MyLink>();

	String n1 = new String("A"); // A
	g.addVertex(n1);
	String n2 = new String("B"); // B
	g.addVertex(n2);

	g.addEdge(new MyLink(2, "A-B"), n1, n2, EdgeType.DIRECTED);

	Transformer<MyLink, Number> weightTrans = new Transformer<MyLink, Number>() {
		@Override
		public Number transform(MyLink link) {
			return link.getWeight();
		}
	};
	SuurballeTarjan<String, MyLink> testMain = new SuurballeTarjan<String, MyLink>(
			g, weightTrans);
	assertEquals("[[A-B]]", testMain.getDisjointPaths(n1, n2).toString());
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:22,代碼來源:SuurballeTarjanTest.java

示例6: reverseEdges

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
/**
 * This method reverse the path "path" in the graph "graph" and returns it.
 * 
 * @param graph
 *            the input graph which will not be changed.
 * @param path
 *            the path to reverse
 * @return a new graph with the reversed path
 */
private Graph<V, E> reverseEdges(Graph<V, E> graph, List<E> path) {
	if (graph == null || path == null)
		throw new IllegalArgumentException();
	Graph<V, E> clone = new DirectedOrderedSparseMultigraph<V, E>();

	for (V v : graph.getVertices())
		clone.addVertex(v);
	for (E e : graph.getEdges())
		clone.addEdge(e, graph.getEndpoints(e));

	for (E link : path) {
		V src = clone.getSource(link);
		V dst = clone.getDest(link);
		clone.removeEdge(link);
		clone.addEdge(link, dst, src, EdgeType.DIRECTED);
	}
	return clone;
}
 
開發者ID:KeepTheBeats,項目名稱:alevin-svn2,代碼行數:28,代碼來源:SuurballeTarjan.java

示例7: switchEdgeBetweenGraphNodes

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
/**
 * Switches the coupling of an edge between an old and a new GraphNode. 
 * This is used for splitting and merging GraphNodes.
 *
 * @param edge the edge to switch between GraphNodes
 * @param newGraphNode the new GraphNode for the edge
 * @param oldGraphNode the old GraphNode for the edge
 * @return the graph node
 */
private GraphEdge switchEdgeBetweenGraphNodes(GraphEdge edge, GraphNode newGraphNode, GraphNode oldGraphNode) {
	
	// Find the node on the other side of the edge
	GraphNode otherNode = this.getGraph().getOpposite(oldGraphNode, edge);
	// Create a new edge with the same ID and type
	GraphEdge newEdge = new GraphEdge(edge.getId(), edge.getComponentType());

	if (this.getGraph().getSource(edge) != null) {
		// if the edge is directed
		if (this.getGraph().getSource(edge)==oldGraphNode) {
			this.getGraph().addEdge(newEdge, newGraphNode, otherNode, EdgeType.DIRECTED);
		} else if (this.getGraph().getDest(edge)==oldGraphNode) {
			this.getGraph().addEdge(newEdge, otherNode, newGraphNode, EdgeType.DIRECTED);
		}
	} else {
		// if the edge is undirected
		this.getGraph().addEdge(newEdge, newGraphNode, otherNode, EdgeType.UNDIRECTED);
	}
	// Removing the old edge from the graph and network model
	this.getGraph().removeEdge(edge);
	graphElements.remove(edge.getId());
	graphElements.put(newEdge.getId(), newEdge);

	return newEdge;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:35,代碼來源:NetworkModel.java

示例8: addToGraph

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
@Override
  public HashSet<GraphElement> addToGraph(NetworkModel networkModel) {
  	
  	Graph<GraphNode, GraphEdge> graph = networkModel.getGraph();
	
// Create nodes and edge
entry = new GraphNode();
entry.setId(networkModel.nextNodeID());
graph.addVertex(entry);

exit = new GraphNode();
exit.setId(networkModel.nextNodeID());
graph.addVertex(exit);

GraphEdge e = new GraphEdge(getId(), getType());
graph.addEdge(e, entry, exit, EdgeType.DIRECTED);
	
// Create a HashSet containing the nodes and edge ant return it
HashSet<GraphElement> elements = new HashSet<GraphElement>();
elements.add(e);
elements.add(entry);
elements.add(exit);
return elements;
  }
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:25,代碼來源:DirectedSimpleGraphElement.java

示例9: checkGraph

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
/**
 * 
 * @param edge_type
 * @param clone
 */
private void checkGraph(EdgeType edge_type, IGraph<DesignerVertex, DesignerEdge> clone) {
    for (DesignerVertex v : graph.getVertices()) {
        DesignerVertex clone_v = graph.getVertex(v.getCatalogItem());
        assertNotNull(clone_v);
    } // FOR
    for (DesignerEdge e : graph.getEdges()) {
        Collection<DesignerVertex> vertices = graph.getIncidentVertices(e);
        DesignerVertex v0 = CollectionUtil.get(vertices, 0);
        assertNotNull(v0);
        DesignerVertex v1 = CollectionUtil.get(vertices, 1);
        assertNotNull(v1);
        
        DesignerVertex clone_v0 = clone.getVertex(v0.getCatalogKey());
        assertNotNull(clone_v0);
        DesignerVertex clone_v1 = clone.getVertex(v1.getCatalogKey());
        assertNotNull(clone_v1);
        Collection<DesignerEdge> clone_e = clone.findEdgeSet(clone_v0, clone_v1);
        assertFalse(clone_e.isEmpty());
        assertEquals(1, clone_e.size());
        assertEquals(edge_type, clone.getEdgeType(CollectionUtil.first(clone_e)));
    } // FOR
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:28,代碼來源:TestGraphUtil.java

示例10: getGraph

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
/**
 * Convert FNSS topology to JUNG graph.
 * 
 * @param topology FNSS Topology object
 * @return A JUNG graph
 */
public static Graph<String, Edge> getGraph(Topology topology) {
	Graph<String, Edge> graph = null;
	EdgeType edgeType = null;
	if (topology.isDirected()) {
		graph = new DirectedSparseGraph<String, Edge>();
		edgeType = EdgeType.DIRECTED;
	} else {
		graph = new UndirectedSparseGraph<String, Edge>();
		edgeType = EdgeType.UNDIRECTED;
	}
	for(String node : topology.getAllNodes()) {
		graph.addVertex(node);
	}
	for(Pair<String, String> edge : topology.getAllEdges()) {
		graph.addEdge(topology.getEdge(edge), edge.getU(), edge.getV(), edgeType);
	}
	return graph;
}
 
開發者ID:fnss,項目名稱:fnss-java,代碼行數:25,代碼來源:JUNGConverter.java

示例11: addEdge

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
/**
	 * Overriding addEdge method from SparseGraph to conform
	 * to the
	 */
/*	@Override
	public boolean addEdge(Edge arg0, java.util.Collection<? extends Vertex> arg1, EdgeType arg2) {
		if(directed) {
			return super.addEdge(arg0, arg1, EdgeType.DIRECTED);
		} else {
			return super.addEdge(arg0, arg1, EdgeType.UNDIRECTED);
		}
	};*/
	
	@Override
	public boolean addEdge(Edge e, Vertex v1, Vertex v2, EdgeType edge_type) {
		if(findEdgeSet(v1, v2).size() > 0 && !multiGraph ) {
			System.err.println("The graph does not allow parallel edges");
			return false;
		}
		if(directed)
			return super.addEdge(e, v1, v2, EdgeType.DIRECTED);
		else
			return super.addEdge(e, v1, v2, EdgeType.UNDIRECTED);
	}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:25,代碼來源:CxfNetwork.java

示例12: createGraphElement

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
private Element createGraphElement(Element root) {
	Element graphEl = doc.createElement("graph");
	root.appendChild(graphEl);

	if (network.getEdgeCount(EdgeType.DIRECTED) > network
			.getEdgeCount(EdgeType.UNDIRECTED)) {
		graphEl.setAttribute("edgedefault", "directed");
	} else {
		graphEl.setAttribute("edgedefault", "undirected");
	}

	// Create nodes
	createNodes(graphEl);

	// Create edges
	createEdges(graphEl);

	return graphEl;
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:20,代碼來源:GraphMLExporter.java

示例13: printEdge

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的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

示例14: testDfs

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
@Test
public void testDfs() throws Exception {

	DirectedGraph<URI, URI> graph = new DirectedSparseGraph<>();
	graph.addVertex( YURI );
	graph.addVertex( YUGO );
	graph.addEdge( YPY, YURI, YUGO, EdgeType.DIRECTED );

	Collection<URI> roots = Arrays.asList( YURI );
	GraphToTreeConverter.Search search = GraphToTreeConverter.Search.DFS;
	Forest<URI, URI> result = GraphToTreeConverter.convert( graph, roots, search );
	assertEquals( 1, result.getTrees().size() );

	Tree<URI, URI> tree = result.getTrees().iterator().next();
	assertEquals( YURI, tree.getRoot() );
	assertEquals( YUGO, tree.getChildren( YURI ).iterator().next() );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:18,代碼來源:GraphToTreeConverterTest.java

示例15: testPrint

import edu.uci.ics.jung.graph.util.EdgeType; //導入依賴的package包/類
@Test
public void testPrint() throws Exception {

	DirectedGraph<URI, URI> graph = new DirectedSparseGraph<>();
	graph.addVertex( YURI );
	graph.addVertex( YUGO );
	graph.addEdge( YPY, YURI, YUGO, EdgeType.DIRECTED );

	Collection<URI> roots = Arrays.asList( YURI );
	GraphToTreeConverter.Search search = GraphToTreeConverter.Search.DFS;
	Forest<URI, URI> result = GraphToTreeConverter.convert( graph, roots, search );

	Logger log = Logger.getLogger( GraphToTreeConverter.class );
	StringWriter stringy = new StringWriter();
	WriterAppender app = new WriterAppender( new SimpleLayout(), stringy );
	log.setLevel( Level.DEBUG );
	log.addAppender( app );
	GraphToTreeConverter.printForest( result );
	String output = stringy.toString().replaceAll( "\\s", "" );
	assertEquals( "DEBUG-http://semoss.va.gov/database/T44889381-85ce-43e3-893d-6267fd480660/YuriDEBUG-http://semoss.va.gov/database/T44889381-85ce-43e3-893d-6267fd480660/Yugo", output );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:22,代碼來源:GraphToTreeConverterTest.java


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