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


Java Tree.getRoot方法代码示例

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


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

示例1: testRenameCluster

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test
public void testRenameCluster() {
     Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
     ClusterVO root = clusters.getRoot();
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
    assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.nullValue());
     try {
        clusterService.renameCluster(1, "CLUSTER1", "CLUSTER3");
     } catch (ClusterException ce) {
         logger.info(ce);
     }
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
     assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.notNullValue());
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:21,代码来源:ClusterServiceTest.java

示例2: actionPerformed

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Override
public void actionPerformed( ActionEvent e ) {
	ValueFactory vf = new ValueFactoryImpl();

	Forest<SEMOSSVertex, SEMOSSEdge> forest
			= GraphToTreeConverter.convertq( graph, selecteds, Search.BFS );

	List<Value[]> rows = new ArrayList<>();
	for ( Tree<SEMOSSVertex, SEMOSSEdge> tree : forest.getTrees() ) {
		SEMOSSVertex root = tree.getRoot();

		// we want a dfs of the tree to keep the nodes in a path together
		Queue<SEMOSSVertex> q = Collections.asLifoQueue( new ArrayDeque<>() );
		q.addAll( tree.getChildren( root ) );
		while ( !q.isEmpty() ) {
			SEMOSSVertex child = q.poll();
			Value row[] = {
				root.getURI(),
				vf.createLiteral( tree.getDepth( child ) ),
				child.getURI(),
				child.getType()
			};
			rows.add( row );

			q.addAll( tree.getChildren( child ) );
		}
	}

	GridPlaySheet grid = new GridPlaySheet();
	grid.create( rows, Arrays.asList( "Root Vertex", "Hops", "Child Vertex",
			"Child Type" ), gps.getEngine() );
	gps.addSibling( "Hops Downstream", grid );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:34,代码来源:DistanceDownstreamProcessor.java

示例3: testGetClustersForTenant

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test
    public void testGetClustersForTenant() {
//        before();

        Tree <ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
        ClusterVO root = clusters.getRoot();

        logger.info("name: " + root.getName());
        logger.info("descr: " + root.getDescription());
        logger.info("id: " + root.getItem().getItem());
        logger.info("tenant: " + root.getItem().getTenant());
        logger.info("type: " + root.getItem().getType());

//        ClusterVO child = new ClusterVO(root.getItem().getTenant(),1000, root.getItem().getType(),"Cluster1", "The first Cluster!");
//        try {
//        clusterService.addCluster(1, "testCluster","This is a testCluster", ClusterService.ROOT);
//        clusterService.addCluster(1, "testCluster2","This is testCluster2", ClusterService.ROOT);
//        clusterService.addCluster(1, "testCluster3","This is testCluster3", ClusterService.ROOT);
//
//        clusterService.addCluster(1, "testCluster4","This is testCluster4", "testCluster");
//        
//        } catch (ClusterException ce) {
//            logger.error(ce);
//        }
//        
//        logger.info(clusters.containsVertex(child));
//        logger.info(clusters.getChildCount(root));
//        logger.info(clusters.getChildCount(child));
//        logger.info(clusters.getParent(child).getName());
//        Collection<ClusterVO> children = clusters.getChildren(root);
//        for (ClusterVO clusterVO : children) {
//            logger.info(clusterVO.getName());
//        }
//
//
//        logger.info(clusters.toString());

    }
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:39,代码来源:ClusterServiceTest.java

示例4: testRemoveCluster

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test
public void testRemoveCluster() {
     Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
     ClusterVO root = clusters.getRoot();
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
     clusterService.removeCluster(1, "CLUSTER1");
     assertThat(clusters.getHeight(), is(1));
     assertThat(clusters.getChildCount(root), is(1));
     assertThat(clusters.getVertexCount(), is(2));
     printCluster(clusters, root);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:15,代码来源:ClusterServiceTest.java

示例5: testMoveCluster

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test
public void testMoveCluster() {
     Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
     ClusterVO root = clusters.getRoot();
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
     clusterService.moveCluster(1, "CLUSTER1", "CLUSTER2");
     assertThat(clusters.getHeight(), is(3));
     assertThat(clusters.getChildCount(root), is(1));
     assertThat(clusters.getVertexCount(), is(5));
     printCluster(clusters, root);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:15,代码来源:ClusterServiceTest.java

示例6: addItemToCluster_shouldThrowWhenNotAdded

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test(expected =  ClusterException.class)
public void addItemToCluster_shouldThrowWhenNotAdded() throws ClusterException {
    Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
    ClusterVO root = clusters.getRoot();
    ItemVO<Integer, Integer> newItem = new ItemVO<Integer, Integer>(TENANT_EASYREC.getId(), 1, 1);

    int rowsModified = clusterService.addItemToCluster(root, newItem);

    assertThat(rowsModified, is(1));

    // this should throw
    rowsModified = clusterService.addItemToCluster(root, newItem);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:14,代码来源:ClusterServiceTest.java

示例7: removeItemFromCluster_shouldThrowWhenNotRemoved

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test(expected = ClusterException.class)
public void removeItemFromCluster_shouldThrowWhenNotRemoved() throws ClusterException {
    Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
    ClusterVO root = clusters.getRoot();
    ItemVO<Integer, Integer> newItem = new ItemVO<Integer, Integer>(TENANT_EASYREC.getId(), 1, 1);

    clusterService.removeItemFromCluster(root, newItem);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:9,代码来源:ClusterServiceTest.java

示例8: getItemsOfCluster_shouldReturnItems

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test
public void getItemsOfCluster_shouldReturnItems() {
    Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
    ClusterVO root = clusters.getRoot();

    List<ItemVO<Integer, Integer>> items = clusterService.getItemsOfCluster(root);

    assertThat(items.size(), is(2));
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:10,代码来源:ClusterServiceTest.java

示例9: testGetClustersForItem

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test
public void testGetClustersForItem() throws ClusterException {
    Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
    ClusterVO root = clusters.getRoot();
    ItemVO<Integer, Integer> newItem = new ItemVO<Integer, Integer>(TENANT_EASYREC.getId(), 1, 1);

    int rowsModified = clusterService.addItemToCluster(root, newItem);
    
    List<ClusterVO> clusterList = clusterService.getClustersForItem(newItem);
    for (ClusterVO clusterVO : clusterList) {
        logger.info(clusterVO.getName());
    }
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:14,代码来源:ClusterServiceTest.java

示例10: addItemToCluster_shouldAddItem_removeItemFromCluster_shouldRemoveItem

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
@Test
public void addItemToCluster_shouldAddItem_removeItemFromCluster_shouldRemoveItem() throws ClusterException {
    Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
    ClusterVO root = clusters.getRoot();

    ItemVO<Integer, Integer> item = new ItemVO<Integer, Integer>(TENANT_EASYREC.getId(), 1,
            1);

    int rowsModified = clusterService.addItemToCluster(root, item);

    assertThat(rowsModified, is(1));

    rowsModified = clusterService.removeItemFromCluster(root, item);

    assertThat(rowsModified, is(1));
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:17,代码来源:ClusterServiceTest.java

示例11: convert

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
public ClusterNode convert(Tree<ClusterVO, ItemAssocVO<Integer,Integer>> tree) {
    ClusterVO root = tree.getRoot();
    
    return writeNode(tree, root, root);
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:6,代码来源:ClusterManagerController.java

示例12: save

import edu.uci.ics.jung.graph.Tree; //导入方法依赖的package包/类
public void save(Tree<ClusterVO, ItemAssocVO<Integer,Integer>> tree,
                 JSONWriter writer) throws JSONException {
    ClusterVO root = tree.getRoot();

    writeNode(tree, root, writer, root);
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:7,代码来源:ClusterManagerController.java


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