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


Java UnionFind类代码示例

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


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

示例1: unifyEquals

import jpaul.DataStructs.UnionFind; //导入依赖的package包/类
private Collection<Constraint<V,Info>> unifyEquals(Collection<Constraint<V,Info>> cs) {
cs = new LinkedList<Constraint<V,Info>>(cs);
uf = new UnionFind<V>();
unifyMutuallySmaller(cs);
boolean changed = true;
while(changed) {
    changed = unifySingleLt(cs, false);
    if(DEBUG) unifySingleLt(cs, true);
    if(eliminateEmpty(cs)) {
	changed = true;
    }
    if(changed) {
	cs = updateConstraints(cs);
    }
}

int nbDisjointVars = 0;
for(V v : vars()) {
    V parent = uf.find(v);
    if(v == parent) nbDisjointVars++;
}
vertexHashCapacity = (3 * nbDisjointVars) / 2;

return cs;
   }
 
开发者ID:protegeproject,项目名称:jpaul,代码行数:26,代码来源:ConstraintSystem.java

示例2: rewrite

import jpaul.DataStructs.UnionFind; //导入依赖的package包/类
public Constraint<V,Info> rewrite(UnionFind<V> uf) {
V vs2 = uf.find(vs);
V vd2 = uf.find(vd);
// remove superfluous constraints
if(vs2.equals(vd2)) return null;
// nothing changed, so why generate a new constraint ?
if(vs.equals(vs2) && vd.equals(vd2)) return this;
return new LtConstraint<V,Info>(vs2, vd2);
   }
 
开发者ID:protegeproject,项目名称:jpaul,代码行数:10,代码来源:LtConstraint.java

示例3: rewrite

import jpaul.DataStructs.UnionFind; //导入依赖的package包/类
/** We implemented {@link #rewrite}, {@link #equals}, and {@link
       #hashCode}, such that constraints that are identical after
       variable unification are not duplicated needlessly. */
   public Constraint<SVar<T>,Set<T>> rewrite(UnionFind<SVar<T>> uf) {
SVar<T> vIn1_p  = uf.find(vIn1);
SVar<T> vIn2_p  = uf.find(vIn2);
SVar<T> vDest_p = uf.find(vDest);	
return new IntersectConstraint<T>(vIn1_p, vIn2_p, vDest_p);
   }
 
开发者ID:protegeproject,项目名称:jpaul,代码行数:10,代码来源:IntersectConstraint.java

示例4: rewrite

import jpaul.DataStructs.UnionFind; //导入依赖的package包/类
/** We implemented {@link #rewrite}, {@link #equals}, and {@link
       #hashCode}, such that constraints that are identical after
       variable unification are not duplicated needlessly. */
   public Constraint<SVar<T>,Set<T>> rewrite(UnionFind<SVar<T>> uf) {
SVar<T> vIn1_p  = uf.find(vIn1);
SVar<T> vIn2_p  = uf.find(vIn2);
SVar<T> vDest_p = uf.find(vDest);	
return new IntersectConstraint(vIn1_p, vIn2_p, vDest_p);
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:10,代码来源:IntersectConstraint.java

示例5: rewrite

import jpaul.DataStructs.UnionFind; //导入依赖的package包/类
public Constraint<V,Info> rewrite(UnionFind<V> uf) {
V vd2 = uf.find(vd);
// nothing changed, so why generate a new constraint ?
if(vd.equals(vd2)) return this;
return new CtConstraint<V,Info>(ct, vd2);
   }
 
开发者ID:protegeproject,项目名称:jpaul,代码行数:7,代码来源:CtConstraint.java

示例6: rewrite

import jpaul.DataStructs.UnionFind; //导入依赖的package包/类
/** We implemented {@link #rewrite}, {@link #equals}, and {@link
       #hashCode}, such that constraints that are identical after
       variable unification are not duplicated needlessly. */
   public Constraint<SVar<T>,Set<T>> rewrite(UnionFind<SVar<T>> uf) {
SVar<T> vIn_p   = uf.find(vIn);
SVar<T> vDest_p = uf.find(vDest);	
return new CtDiffConstraint<T>(vIn_p, ctSet, vDest_p);
   }
 
开发者ID:protegeproject,项目名称:jpaul,代码行数:9,代码来源:CtDiffConstraint.java

示例7: rewrite

import jpaul.DataStructs.UnionFind; //导入依赖的package包/类
/** Rewrites <code>this</code> constraint by replacing each
variable with the representative of its equivalence class.
The real implementation of this method is optional: the
default implementation returns <code>this</code> constraint,
unmodified.  This is safe: the constraint writer does not need
to be aware of variable unification, as the
<code>SolAccessor</code> passed by the constraint solver
already deals with it.

<p>Implementing <code>rewrite</code> may be useful when
unification causes several constraints to become identical:
e.g., consider <code>v1 &lt;= v2</code> and <code>v3 &lt;=
v4</code>, after we unify <code>v1</code> with <code>v3</code>
and <code>v2</code> with <code>v4</code>.  Implementing
<code>rewrite</code>, <code>equals</code> (and
<code>hashCode</code>) allows the solver to avoid working with
several identical constraints.

@param uf Union-find structure; for each variable
<code>v</code>, <code>uf.find(v)</code> is the representative
of its equivalence class. */
   public Constraint<V,Info> rewrite(UnionFind<V> uf) {
return this;
   }
 
开发者ID:protegeproject,项目名称:jpaul,代码行数:25,代码来源:Constraint.java


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