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


Java Forest类代码示例

本文整理汇总了Java中edu.uci.ics.jung.graph.Forest的典型用法代码示例。如果您正苦于以下问题:Java Forest类的具体用法?Java Forest怎么用?Java Forest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Forest类属于edu.uci.ics.jung.graph包,在下文中一共展示了Forest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBfs

import edu.uci.ics.jung.graph.Forest; //导入依赖的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: MinimumSpanningForest

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
/**
 * Creates a minimum spanning forest from the supplied graph, populating the
 * supplied Forest, which must be empty. 
 * If the supplied root is null, or not present in the Graph,
 * then an arbitrary Graph vertex will be selected as the root.
 * If the Minimum Spanning Tree does not include all vertices of the
 * Graph, then a leftover vertex is selected as a root, and another
 * tree is created
 * @param graph the Graph to find MST in
 * @param forest the Forest to populate. Must be empty
 * @param root first Tree root, may be null
 */
public MinimumSpanningForest(Graph<V, E> graph, Forest<V,E> forest, 
        Collection<V> roots) {
    
    if(forest.getVertexCount() != 0) {
        throw new IllegalArgumentException("Supplied Forest must be empty");
    }
    this.graph = graph;
    this.forest = forest;
    Set<E> unfinishedEdges = new HashSet<E>(graph.getEdges());
    if(roots != null && !roots.isEmpty()) {
    	V root = roots.iterator().next();
    	System.out.println(root);
    	roots.remove(root);
    	this.forest.addVertex(root);
    }
    updateForest(forest.getVertices(), unfinishedEdges, roots);
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:30,代码来源:MinimumSpanningForest.java

示例3: testDfs

import edu.uci.ics.jung.graph.Forest; //导入依赖的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

示例4: testPrint

import edu.uci.ics.jung.graph.Forest; //导入依赖的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

示例5: LayoutPopup

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
/**
 * Constructor for LayoutPopup.
 *
 * @param name String
 * @param ps IPlaySheet
 */
public LayoutPopup( String name, GraphPlaySheet ps, Collection<SEMOSSVertex> verts ) {
	super( name );

	DirectedGraph<SEMOSSVertex, SEMOSSEdge> viz = ps.getVisibleGraph();
	boolean forestok = ( viz instanceof Forest || !verts.isEmpty() );

	for ( Class<? extends Layout> layout : LAYOUTS ) {
		LayoutMenuItem mi = new LayoutMenuItem( layout, ps, verts );
		add( mi );

		if ( TREELAYOUTS.contains( layout ) ) {
			mi.setEnabled( forestok );
		}
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:22,代码来源:LayoutPopup.java

示例6: actionPerformed

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
@Override
public void actionPerformed( ActionEvent ae ) {
	boolean done = false;
	if ( !( gps.getGraphData().getGraph() instanceof Forest ) ) {
		// if we're not already a tree, but the user selected a tree layout
		// *AND* at least one tree root, then convert to a tree before
		// processing the layout

		if ( LayoutPopup.TREELAYOUTS.contains( layout ) && !verts.isEmpty() ) {
			Logger.getLogger( getClass() ).debug( "automatically converting to a tree layout" );

			TreeGraphPlaySheet tgps = new TreeGraphPlaySheet( gps.getGraphData().getGraph(),
					gps.getView().getPickedVertexState().getPicked(), layout );
			tgps.setTitle( "Tree Conversion" );
			gps.addSibling( tgps );
			done = true;
		}
	}

	if ( !done ) {
		// normal, non-tree layout
		gps.getView().setGraphLayout( this.layout );
	}
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:25,代码来源:LayoutMenuItem.java

示例7: generateGraph

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
private Forest generateGraph()
    {
        /*position vertices in graph*/
//        DirectedSparseGraph<Node, HyperEdge> graph  =
//                new DirectedSparseGraph<Node, HyperEdge>();
        DelegateTree graph  =
                new DelegateTree<HyperEdge, Node>();
        EventsNode ev0 = new EventsNode(0, 5);
//        TrackNode tr1 = new TrackNode(0, 1, 0, 0, true, true);
        TrackNode tr1 = new TrackNode(0, 1, 0, 0);
        EventsNode ev1 = new EventsNode(1, 0);
        graph.addVertex(ev0);
        graph.addChild(new HyperEdge(1.0), ev0, ev1);
        graph.addChild(new HyperEdge(1.0), ev0, tr1);
        
//        graph.addEdge(ev0, Arrays.asList(ev1, tr1));
//        graph.addEdge(new HyperEdge(1.0), ev0, tr1);

        return graph;
    }
 
开发者ID:sinantie,项目名称:Generator,代码行数:21,代码来源:VisualiseHypergraph.java

示例8: collapse

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void collapse(Layout layout, Forest tree, Object subRoot) throws InstantiationException, IllegalAccessException {
       
   	// get a sub tree from subRoot
   	Forest subTree = TreeUtils.getSubTree(tree, subRoot);
   	Object parent = null;
   	Object edge = null;
   	if(tree.getPredecessorCount(subRoot) > 0) {
   		parent = tree.getPredecessors(subRoot).iterator().next();
   		edge = tree.getInEdges(subRoot).iterator().next();
   	}	
   	tree.removeVertex(subRoot);
   	if(parent != null) {
   		tree.addEdge(edge, parent, subTree);
   	} else {
   		tree.addVertex(subTree);
   	}
   	
   	layout.setLocation(subTree, (Point2D)layout.transform(subRoot));
   }
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:21,代码来源:TreeCollapser.java

示例9: MinimumSpanningForest

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
/**
 * Creates a minimum spanning forest from the supplied graph, populating the
 * supplied Forest, which must be empty. 
 * If the supplied root is null, or not present in the Graph,
 * then an arbitrary Graph vertex will be selected as the root.
 * If the Minimum Spanning Tree does not include all vertices of the
 * Graph, then a leftover vertex is selected as a root, and another
 * tree is created
 * @param graph the Graph to find MST in
 * @param forest the Forest to populate. Must be empty
 * @param root first Tree root, may be null
 * @param weights edge weights, may be null
 */
public MinimumSpanningForest(Graph<V, E> graph, Forest<V,E> forest, 
		V root, Map<E, Double> weights) {
	
	if(forest.getVertexCount() != 0) {
		throw new IllegalArgumentException("Supplied Forest must be empty");
	}
	this.graph = graph;
	this.forest = forest;
	if(weights != null) {
		this.weights = weights;
	}
	Set<E> unfinishedEdges = new HashSet<E>(graph.getEdges());
	if(graph.getVertices().contains(root)) {
		this.forest.addVertex(root);
	}
	updateForest(forest.getVertices(), unfinishedEdges);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:31,代码来源:MinimumSpanningForest.java

示例10: LayoutSelection

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
public LayoutSelection(GraphViewer<V, E> graphViewer, Graph<V, E> graph) {
	super();
	this.graphViewer = graphViewer;
	this.graph = graph;
	this.layout = new ISOMLayout<V, E>(graph);

	layoutMap = new java.util.LinkedHashMap<String, Class>();

	if (graph instanceof Forest) {
		layoutMap.put("Tree", ShapeBasedTreeLayout.class);
		layoutMap.put("Tree (Tight)", TreeLayout.class);
		layoutMap.put("Radial", RadialTreeLayout.class);
		layoutMap.put("Balloon", BalloonLayout.class);
	}

	layoutMap.put("ISOM", ISOMLayout.class);
	layoutMap.put("KKLayout", KKLayout.class);
	layoutMap.put("FRLayout", FRLayout2.class);
	layoutMap.put("Circle", CircleLayout.class);
	layoutMap.put("Spring", SpringLayout2.class);

	Iterator<String> it = layoutMap.keySet().iterator();
	while (it.hasNext()) {
		addItem(it.next());
	}

	addActionListener(this);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:LayoutSelection.java

示例11: getRoots

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
private Collection<V> getRoots(Forest<V, E> forest) {
	Set<V> roots = new HashSet<V>();
	for (Tree<V, E> tree : forest.getTrees()) {
		roots.add(tree.getRoot());
	}
	return roots;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:8,代码来源:ShapeBasedTreeLayout.java

示例12: setGraph

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
@Override
public void setGraph(Graph<V, E> graph) {
	if (graph instanceof Forest) {
		this.graph = (Forest<V, E>) graph;
		calculateLocations();
	} else {
		throw new IllegalArgumentException("graph must be a Forest");
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:10,代码来源:ShapeBasedTreeLayout.java

示例13: factory

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
public static <V, E> GraphVisualizationPanel<V, E> factory(Graph<V, E> graph) {
    Layout<V, E> layout = null;
    if (graph instanceof DelegateForest) { 
        layout = new TreeLayout<V, E>((Forest<V, E>) graph);
    } else if (graph instanceof MarkovGraph){
        layout = new FRLayout<V,E>(graph);
    } else if (graph instanceof ConflictGraph){
        layout = new KKLayout<V, E>(graph);
    } else if (graph instanceof AbstractDirectedGraph) {
        layout = new DAGLayout<V, E>(graph);
    } else {
        layout = new CircleLayout<V, E>(graph);
    }
    return (new GraphVisualizationPanel<V, E>(layout, graph));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:16,代码来源:GraphVisualizationPanel.java

示例14: setGraph

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
@Override
public void setGraph(Graph<ViwnNode, ViwnEdge> graph) {
    if (graph instanceof Forest) {
        this.graph = (Forest<ViwnNode, ViwnEdge>) graph;
    } else {
        throw new IllegalArgumentException("visualisation must be a Forest");
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:9,代码来源:ViwnLayout.java

示例15: BrowsableForestNetwork

import edu.uci.ics.jung.graph.Forest; //导入依赖的package包/类
public BrowsableForestNetwork(BrowsableNetwork originalNetwork) {
	if(originalNetwork instanceof BrowsableForestNetwork) {
		// if the original network is a forest, we are interested in the original network
		this.originalNetwork = ((BrowsableForestNetwork)originalNetwork).getOriginalNetwork();
	} else {
		this.originalNetwork = originalNetwork;
	}
	Forest<Vertex, Edge> forest = new DelegateForest<Vertex, Edge>();		
	new MinimumSpanningForest<Vertex, Edge>(originalNetwork, forest, getRoots(this.originalNetwork));
	this.forest = forest;
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:12,代码来源:BrowsableForestNetwork.java


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