本文整理匯總了Java中nl.peterbloem.kit.Pair類的典型用法代碼示例。如果您正苦於以下問題:Java Pair類的具體用法?Java Pair怎麽用?Java Pair使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Pair類屬於nl.peterbloem.kit包,在下文中一共展示了Pair類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: Run
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
public Run(UGraph<String> sub, int instances, int run, double frequency, double factor)
{
super();
this.sub = sub;
this.instances = instances;
this.run = run;
this.frequency = frequency;
this.factor = factor;
Pair<UGraph<String>, Integer> pair = Pair.p(sub, instances);
if(! all.containsKey(pair))
{
List<Run> list = new ArrayList<Run>(runs);
for(int i : series(runs))
list.add(null);
all.put(pair, list);
}
all.get(pair).set(run, this);
}
示例2: equals
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Pair other = (Pair) obj;
if (a != other.a)
return false;
if (b != other.b)
return false;
return true;
}
示例3: read
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
private void read()
{
if(next >= LightDTGraph.this.size())
return;
while(buffer.size() < BUFFER_LIMIT && next < LightDTGraph.this.size())
{
int from = next;
List<Integer> tos = out.get(from);
for (int i = 0; i < tos.size(); i++)
buffer.add(new Pair<Pair<Integer,Integer>,Integer>(new Pair<Integer, Integer>(from, tos.get(i)), i));
next++;
}
}
示例4: read
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
private void read()
{
if(next >= LightDGraph.this.size())
return;
while(buffer.size() < BUFFER_LIMIT && next < LightDGraph.this.size())
{
int from = next;
List<Integer> tos = out.get(from);
for(int to : tos)
buffer.add(new Pair<Integer, Integer>(from, to));
next++;
}
}
示例5: confidence
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
/**
* Returns a confidence interval, in log space, for the estimate of the
* logarithm of the number of graphs.
*
* @param alpha
* @param method
* @param type
* @return
*/
public Pair<Double, Double> confidence(double alpha, CIMethod method, CIType type)
{
if(logSamples.isEmpty())
throw new IllegalStateException("logSamples is empty. Cannot compute CI before samples have been created");
if(method == STANDARD)
return confidenceStandard(alpha, type);
if(method == CIMethod.LOG_NORMAL)
return confidenceLogNormal(alpha, type);
if(method == CIMethod.PERCENTILE || method == CIMethod.BCA)
return confidenceBootstrap(alpha, method, type);
return null;
}
示例6: read
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
private void read()
{
if(next >= DiskDGraph.this.size())
return;
while(buffer.size() < BUFFER_LIMIT && next < DiskDGraph.this.size())
{
int from = next;
List<Integer> tos = out.get(from);
for(int to : tos)
buffer.add(new Pair<Integer, Integer>(from, to));
next++;
}
}
示例7: toPairUndirected
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
public static Pair<Integer, Integer> toPairUndirected(int index,
boolean self)
{
double iDouble;
int i, j;
if (self)
{
iDouble = -0.5 + 0.5 * Math.sqrt(1.0 + 8.0 * index);
i = (int) Math.floor(iDouble);
j = index - ((i * (i + 1)) / 2);
} else
{
iDouble = 0.5 + 0.5 * Math.sqrt(1.0 + 8.0 * index);
i = (int) Math.floor(iDouble);
j = index - ((i * (i - 1)) / 2);
}
return new Pair<Integer, Integer>(i, j);
}
示例8: primeSignature
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
/**
* The prime signature of a node in a directed, tagged graph is the combination
* of 'in/out' and a tag which occurs most frequently among all links connected
* to the node.
*
* @param node
* @return A pair
*/
public static <L, T> Pair<Dir, T> primeSignature(DTNode<L, T> node)
{
FrequencyModel<Pair<Dir, T>> frequencies = new FrequencyModel<Pair<Dir,T>>();
for(DTLink<L, T> link : node.links())
{
// * Ignore self links
if(link.from().equals(link.to()))
continue;
Dir dir = link.from().equals(node) ? Dir.OUT : Dir.IN;
frequencies.add(new Pair<Dir, T>(dir, link.tag()));
}
return frequencies.maxToken();
}
示例9: primeDegree
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
/**
* @param node
* @return
*/
public static <L, T> int primeDegree(DTNode<L, T> node)
{
FrequencyModel<Pair<Dir, T>> frequencies = new FrequencyModel<Pair<Dir,T>>();
for(DTLink<L, T> link : node.links())
{
// * Ignore self links
if(link.from().equals(link.to()))
continue;
Dir dir = link.from().equals(node) ? Dir.OUT : Dir.IN;
frequencies.add(new Pair<Dir, T>(dir, link.tag()));
}
return (int)frequencies.frequency(frequencies.maxToken());
}
示例10: random
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
/**
* Makes a uniform random selection from the set of all graphs with exactly
* n nodes and m links. Nodes will not connect to themselves
*
* @param n
* @param m
* @return
*/
public static UTGraph<String, String> random(int n, int m)
{
UTGraph<String, String> graph = new MapUTGraph<String, String>();
for(int i : series(n))
graph.add("x");
long ln = (long)n;
long total = (ln*ln - ln) / (long)2;
List<Long> indices = Functions.sample(m, total);
for(long index : indices)
{
Pair<Integer, Integer> ij = toPairUndirected(index, false);
graph.nodes().get(ij.first()).connect(graph.nodes().get(ij.second()));
}
return graph;
}
示例11: randomFast
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
public static UGraph<String> randomFast(int n, int m)
{
UGraph<String> graph = new LightUGraph<String>();
for(int i : series(n))
graph.add("x");
long ln = (long)n;
long total = (ln*ln - ln) / (long)2;
List<Long> indices = Functions.sample(m, total);
for(long index : indices)
{
Pair<Integer, Integer> ij = toPairUndirected(index, false);
graph.get(ij.first()).connect(graph.get(ij.second()));
}
return graph;
}
示例12: toPairUndirected
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
/**
* Returns the pair of indicesencoded by the given index.
*
*
* NB: may overflow if the resulting indices are too big.
*
* @param index
* @param self
* @return
*/
public static Pair<Integer, Integer> toPairUndirected(long index, boolean self)
{
double iDouble;
long i, j;
if(self)
{
iDouble = - 0.5 + 0.5 * Math.sqrt(1.0 + 8.0 * index);
i = (int) Math.floor(iDouble);
j = index - ((i * (i + 1)) / 2);
} else {
iDouble = 0.5 + 0.5 * Math.sqrt(1.0 + 8.0 * index);
i = (int) Math.floor(iDouble);
j = index - ((i * (i - 1)) / 2);
}
return new Pair<Integer, Integer>((int)i, (int)j);
}
示例13: testIndex
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
@Test
public void testIndex()
{
Global.randomSeed();
for(int t : Series.series(10000000))
{
int index = Global.random().nextInt(100);
Pair<Integer, Integer> ij = Functions.toPairUndirected(index, true);
assertEquals(index, Functions.toIndexUndirected(ij.first(), ij.second(), true));
int i = Global.random().nextInt(100), j = Global.random().nextInt(i + 1);
index = Functions.toIndexUndirected(i, j, true);
ij = Functions.toPairUndirected(index, true);
assertEquals(i, (int)ij.first());
assertEquals(j, (int)ij.second());
}
}
示例14: sizeERInst
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
/**
* A version of the ER model that loops only over the instances. It requires
* the degrees of the graph to be given.
*
* @param graph
* @param degrees
* @param sub
* @param occurrences
* @param resetWiring
* @return
*/
public static double sizeERInst(UGraph<?> graph, UGraph<?> sub,
List<List<Integer>> occurrences, boolean resetWiring)
{
FrequencyModel<String> bits = new FrequencyModel<String>();
bits.add("sub", erModel.codelength(sub));
FrequencyModel<Pair<Integer, Integer>> multiEdges = new FrequencyModel<Pair<Integer, Integer>>();
List<List<Integer>> rewiring = new LinkedList<List<Integer>>();
Pair<Long, Long> pair = subbedERInstances(graph, sub, occurrences, multiEdges, rewiring);
// * store the template graph (as a simple graph)
bits.add("subbed", ERSimpleModel.undirected(pair.first(), pair.second(), true));
// * store the multi-edges
// - We are storing, for each link, the number of additional edges required
// (so everything's - 1)
bits.add("multi-edges", multiEdges(multiEdges));
// * Store the rewiring information
bits.add("wiring", wiringBits(sub, rewiring, resetWiring));
// * Store the insertion order, to preserve the precise ordering of the
// nodes in the data
int subbedSize = graph.size() - (sub.size() - 1) * occurrences.size();
bits.add("insertions", log2Factorial(graph.size()) - log2Factorial(subbedSize));
bits.add("labels", Functions.prefix(occurrences.size()) + log2Choose(occurrences.size(), subbedSize));
// bits.print(System.out);
return bits.total();
}
示例15: sizeEL
import nl.peterbloem.kit.Pair; //導入依賴的package包/類
/**
* A version of the EL model that loops only over the instances. It requires
* the degrees of the graph to be given.
*
* @param graph
* @param degrees
* @param sub
* @param occurrences
* @param resetWiring
* @return
*/
public static double sizeEL(UGraph<?> graph, List<Integer> degrees, UGraph<?> sub,
List<List<Integer>> occurrences, boolean resetWiring)
{
FrequencyModel<String> bits = new FrequencyModel<String>();
bits.add("sub", elModel.codelength(sub));
FrequencyModel<Pair<Integer, Integer>> multiEdges = new FrequencyModel<Pair<Integer, Integer>>();
List<List<Integer>> rewiring = new LinkedList<List<Integer>>();
List<Integer> sDegrees = subbedDegrees(graph, degrees, occurrences, multiEdges, rewiring);
// * store the template graph (as a simple graph)
bits.add("subbed", EdgeListModel.undirected(sDegrees, Prior.COMPLETE));
// * store the multi-edges
bits.add("multi-edges", multiEdges(multiEdges));
// * Store the rewiring information
bits.add("wiring", wiringBits(sub, rewiring, resetWiring));
// * Store the insertion order, to preserve the precise ordering of the
// nodes in the data
int subbedSize = graph.size() - (sub.size() - 1) * occurrences.size();
assert(sDegrees.size() == subbedSize);
bits.add("insertions", log2Factorial(graph.size()) - log2Factorial(subbedSize));
bits.add("labels", Functions.prefix(occurrences.size()) + log2Choose(occurrences.size(), subbedSize));
// bits.print(System.out);
return bits.total();
}