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


Java DelegateTree.containsVertex方法代码示例

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


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

示例1: addCluster

import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的package包/类
public void addCluster(ClusterVO cluster, ClusterVO parent) throws ClusterException {

        DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>> tree =
                clusters.get(parent.getItem().getTenant());
        if (tree.containsVertex(cluster)) throw new ClusterException("Cannot add cluster! Cluster already exists!");
        if (tree.containsVertex(parent)) {
            storeCluster(cluster);
            ItemAssocVO<Integer,Integer> edge =
                    new ItemAssocVO<Integer,Integer>(
                            parent.getItem().getTenant(), // tenantId
                            parent.getItem(), //itemFrom
                            assocTypeDAO.getIdOfType(parent.getItem().getTenant(), ClusterService.ASSOCTYPE_CLUSTER),
                            //assocType
                            1.0, //assocValue
                            cluster.getItem(), //itemTo
                            sourceTypeDAO.getIdOfType(parent.getItem().getTenant(),
                                    SourceTypeDAO.SOURCETYPE_MANUALLY_CREATED), //sourceType
                            "", //comment
                            viewTypeDAO.getIdOfType(parent.getItem().getTenant(), ViewTypeDAO.VIEWTYPE_ADMIN),
                            true); //timeStamp
            itemAssocService.insertOrUpdateItemAssoc(edge);
            tree.addChild(edge, parent, cluster);
        } else {
            throw new ClusterException("Parent cluster could not be found!");
        }

        //check if profile with name already exists
        // if yes reject : cluster already exists
        // else check if parent exists, if not reject.
        // find parent;
        // insert child;
        // store itemassoc
    }
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:34,代码来源:ClusterServiceImpl.java

示例2: iconvert

import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的package包/类
private Tree<V, E> iconvert( DirectedGraph<V, E> graph, V root,
		boolean throwExceptions ) throws TreeConversionException {

	ArrayDeque<V> deque = new ArrayDeque<>();
	Queue<V> todo = ( Search.DFS == method
			? Collections.asLifoQueue( deque )
			: deque );

	DelegateTree<V, E> tree = new DelegateTree<>();
	tree.setRoot( root );
	todo.add( root );

	// avoid cycles in the graph
	Set<E> edgesToSkip = new HashSet<>();

	while ( !todo.isEmpty() ) {
		V v = todo.poll();

		// once we visit a node, we can never end
		// up there again, or we're not acyclic
		edgesToSkip.addAll( graph.getInEdges( v ) );

		Set<E> outgoings = new HashSet<>( graph.getOutEdges( v ) );
		outgoings.removeAll( edgesToSkip );

		for ( E e : outgoings ) {
			V child = graph.getOpposite( v, e );

			if ( tree.containsVertex( child ) ) {
				if ( throwExceptions ) {
					throw new TreeConversionException();
				}
			}
			else {
				tree.addChild( e, v, child );
				todo.add( child );
			}
		}
	}

	return tree;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:43,代码来源:GraphToTreeConverter.java


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