本文整理汇总了Java中edu.uci.ics.jung.graph.DelegateTree.addChild方法的典型用法代码示例。如果您正苦于以下问题:Java DelegateTree.addChild方法的具体用法?Java DelegateTree.addChild怎么用?Java DelegateTree.addChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uci.ics.jung.graph.DelegateTree
的用法示例。
在下文中一共展示了DelegateTree.addChild方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateGraph
import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的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;
}
示例2: buildTree
import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的package包/类
private void buildTree(
DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>> tree,
ClusterVO vertex) {
Integer assocTypeCluster =
assocTypeDAO.getIdOfType(vertex.getItem().getTenant(), ClusterService.ASSOCTYPE_CLUSTER);
List<ItemAssocVO<Integer,Integer>> edges = itemAssocService
.getItemAssocs(vertex.getItem(), assocTypeCluster, null,
new IAConstraintVO<Integer, Integer>(null, vertex.getItem().getTenant()));
for (ItemAssocVO<Integer,Integer> edge : edges) {
ItemVO<Integer, Integer> child = edge.getItemTo();
ClusterVO childVertex = loadCluster(child.getTenant(), child.getItem(), child.getType());
if (childVertex != null) {
tree.addChild(edge, vertex, childVertex);
buildTree(tree, childVertex);
}
}
}
示例3: getConstraintSolverHierarchy
import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的package包/类
/**
* Get the hierarchy of {@link ConstraintSolver}s rooted in this {@link MultiConstraintSolver}.
* @return The hierarchy of {@link ConstraintSolver}s rooted in this {@link MultiConstraintSolver}.
*/
public DelegateTree<ConstraintSolver,String> getConstraintSolverHierarchy() {
DelegateTree<ConstraintSolver,String> ret = new DelegateTree<ConstraintSolver, String>();
ret.setRoot(this);
ConstraintSolver[] myConstraintSolvers = this.getConstraintSolvers();
for (int i = 0; i < myConstraintSolvers.length; i++) {
String edgeLabel = i + " (" + this.hashCode() + ")";
if (myConstraintSolvers[i] instanceof MultiConstraintSolver) {
DelegateTree<ConstraintSolver,String> subtree = ((MultiConstraintSolver)myConstraintSolvers[i]).getConstraintSolverHierarchy();
TreeUtils.addSubTree(ret, subtree, this, edgeLabel);
}
else {
ret.addChild(edgeLabel, this, myConstraintSolvers[i]);
}
}
return ret;
}
示例4: getConstraintNetworkHierarchy
import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的package包/类
/**
* Get a tree whose nodes are the constraint networks managed by the hierarchy of
* {@link ConstraintSolver}s underlying this {@link MultiConstraintSolver}.
* @return A tree whose nodes are the constraint networks managed by the hierarchy of
* {@link ConstraintSolver}s underlying this {@link MultiConstraintSolver}.
*/
public DelegateTree<ConstraintNetwork,String> getConstraintNetworkHierarchy() {
DelegateTree<ConstraintNetwork,String> ret = new DelegateTree<ConstraintNetwork, String>();
ConstraintNetwork myCN = this.getConstraintNetwork();
ret.setRoot(myCN);
ConstraintSolver[] myConstraintSolvers = this.getConstraintSolvers();
for (int i = 0; i < myConstraintSolvers.length; i++) {
String edgeLabel = i + " (" + this.hashCode() + ")";
if (myConstraintSolvers[i] instanceof MultiConstraintSolver) {
DelegateTree<ConstraintNetwork,String> subtree = ((MultiConstraintSolver)myConstraintSolvers[i]).getConstraintNetworkHierarchy();
TreeUtils.addSubTree(ret, subtree, myCN, edgeLabel);
}
else {
ret.addChild(edgeLabel, myCN, myConstraintSolvers[i].getConstraintNetwork());
}
}
return ret;
}
示例5: 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
}
示例6: moveCluster
import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的package包/类
public void moveCluster(Integer tenantId, String clusterName, String newParent) {
DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>> tree =
clusters.get(tenantId);
ClusterVO cluster = loadCluster(tenantId, idMappingDAO.lookup(clusterName),
itemTypeDAO.getIdOfType(tenantId, ClusterService.ITEMTYPE_CLUSTER));
// disconnect subtree
ItemAssocVO<Integer,Integer> parentEdge = tree.getParentEdge(cluster);
itemAssocService.removeItemAssoc(parentEdge.getId());
tree.removeChild(cluster);
// add cluster as child to new parent
ClusterVO parent = loadCluster(tenantId, idMappingDAO.lookup(newParent),
itemTypeDAO.getIdOfType(tenantId, ClusterService.ITEMTYPE_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);
buildTree(tree, cluster);
}
示例7: getVariableHierarchy
import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的package包/类
/**
* Get the hierarchy of {@link Variable}s underlying this {@link MultiVariable}.
* @return The hierarchy of {@link Variable}s underlying this {@link MultiVariable}.
*/
public DelegateTree<Variable,String> getVariableHierarchy() {
DelegateTree<Variable,String> ret = new DelegateTree<Variable, String>();
ret.setRoot(this);
Variable[] myVars = this.getInternalVariables();
for (int i = 0; i < myVars.length; i++) {
String edgeLabel = i + " (" + this.getConstraintSolver().hashCode() + ")";
if (myVars[i] instanceof MultiVariable) {
DelegateTree<Variable,String> subTree = ((MultiVariable)myVars[i]).getVariableHierarchy();
TreeUtils.addSubTree(ret, subTree, this, edgeLabel);
}
else ret.addChild(edgeLabel, this, myVars[i]);
}
return ret;
}
示例8: convert
import edu.uci.ics.jung.graph.DelegateTree; //导入方法依赖的package包/类
/**
* Creates a tree using random, unique URIs instead of actual vertices and
* nodes. The lookup maps are populated with the conversions. NOTE: the Tree
* can contain duplicates in the sense that different URIs might map to the
* same vertex/edge.
*
* @param graph the graph to convert
* @param root the root of the tree
* @param vlookup a (usually empty) map that will be populated with the
* uri-to-vertex lookup
* @param elookup a (usually empty) map that will be populated with the
* uri-to-edge lookup
* @return a valid tree, no matter what
*/
public Tree<URI, URI> convert( DirectedGraph<V, E> graph,
V root, Map<URI, V> vlookup, Map<URI, E> elookup ) {
DelegateTree<URI, URI> tree = new DelegateTree<>();
Map<V, URI> revlkp = new HashMap<>();
ArrayDeque<V> deque = new ArrayDeque<>();
Queue<V> todo = ( Search.DFS == method
? Collections.asLifoQueue( deque )
: deque );
URI rootu = Utility.getUniqueUri();
vlookup.put( rootu, root );
revlkp.put( root, rootu );
tree.setRoot( rootu );
// avoid cycles in the graph
Set<E> edgesToSkip = new HashSet<>();
todo.add( root );
while ( !todo.isEmpty() ) {
V v = todo.poll();
URI srcuri = revlkp.get( v );
// 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 );
URI edgeuri = Utility.getUniqueUri();
URI tgturi = Utility.getUniqueUri();
elookup.put( edgeuri, e );
vlookup.put( tgturi, child );
revlkp.put( child, tgturi );
tree.addChild( edgeuri, srcuri, tgturi );
todo.add( child );
}
}
return tree;
}
示例9: 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;
}