本文整理汇总了Java中nl.peterbloem.kit.Global类的典型用法代码示例。如果您正苦于以下问题:Java Global类的具体用法?Java Global怎么用?Java Global使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Global类属于nl.peterbloem.kit包,在下文中一共展示了Global类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import nl.peterbloem.kit.Global; //导入依赖的package包/类
public void main() throws IOException
{
Global.randomSeed();
loadData();
int nodes = data.size();
long links = data.numLinks();
int sig;
long t0 = System.nanoTime();
if(undirected)
sig = undirected();
else
sig = directed();
double elapsed = (System.nanoTime() - t0) / 1.0e9;
String rand = String.format("%d05", Global.random().nextInt(10000));
BufferedWriter writer = new BufferedWriter(new FileWriter(new File("output."+rand+".csv")));
writer.write(id + ", " + undirected + ", " + nodes + ", " + links + ", " + sig + ", " + sampleTime + ", " + elapsed + "\n");
writer.close();
}
示例2: go
import nl.peterbloem.kit.Global; //导入依赖的package包/类
public void go(long seed)
{
Global.setSeed(seed);
DGraph<String> graph = RandomGraphs.randomDirectedFast(1000, 500000);
graph = DiskDGraph.copy(graph, new File("./tmp/"));
DPlainMotifExtractor<String> ex = new DPlainMotifExtractor<>(graph, 100, 4, 3);
List<D> degrees = DSequenceEstimator.sequence(graph);
for(DGraph<String> sub : ex.subgraphs())
{
List<List<Integer>> occ = ex.occurrences(sub);
try
{
MotifSearchModel.sizeELInst(graph, degrees, sub, occ, true, -1);
} catch(RuntimeException e)
{
Global.log().info("seed " + Global.randomSeed());
throw e;
}
}
FileIO.rDelete(new File("./tmp"));
}
示例3: testOverlapTiming
import nl.peterbloem.kit.Global; //导入依赖的package包/类
@Test
public void testOverlapTiming()
{
double sum = 0.0;
int size = 1000;
for(int i : series(1000))
{
int[] a = new int[size];
int[] b = new int[size];
for(int j : series(size))
{
a[j] = Global.random().nextInt();
b[j] = Global.random().nextInt();
tic();
Orca.overlap(a, b);
sum += toc();
}
}
System.out.println("time: " + sum + " seconds.");
}
示例4: read
import nl.peterbloem.kit.Global; //导入依赖的package包/类
public static Classified<UTGraph<Integer, Integer>> read(File directory)
throws IOException
{
Classified<UTGraph<Integer, Integer>> result = Classification.empty();
FileFilter filter = new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isFile() && pathname.getName().endsWith(".graph");
}
};
for(File file : directory.listFiles(filter))
loadGraph(file, result);
Global.log().info(result.size() + " graphs loaded. ");
return result;
}
示例5: sequence
import nl.peterbloem.kit.Global; //导入依赖的package包/类
public static <L> List<D> sequence(DGraph<L> graph)
{
List<D> list = new ArrayList<D>(graph.size());
long t0 = System.currentTimeMillis();
for(DNode<L> node : graph.nodes())
{
list.add(new D(node.inDegree(), node.outDegree()));
if(System.currentTimeMillis() - t0 > 600000) // give an update every ten minutes
{
Global.log().info("Reading degree sequence. " + node.index() + " nodes of " + graph.size() + " processed");
t0 = System.currentTimeMillis();
}
}
return list;
}
示例6: expandBuffer
import nl.peterbloem.kit.Global; //导入依赖的package包/类
/**
* Expands the buffer until the first element is a leaf state. If that's
* not possible, it returns.
*/
private void expandBuffer()
{
if(buffer.isEmpty())
return;
while(! buffer.peek().isLeaf())
{
State next = buffer.pop();
if(probs == null || Global.random().nextDouble() < probs.get(next.indices().size() - 1))
for(State state : next.children())
buffer.add(0, state);
if(buffer.isEmpty())
return;
}
assert(buffer.isEmpty() || buffer.peek().isLeaf());
}
示例7: directed
import nl.peterbloem.kit.Global; //导入依赖的package包/类
public double directed(DGraph<N> graph, List<Integer> order)
{
long n = graph.size();
long k = graph.numLinks();
double sizeBits = Functions.prefix(n);
sizeBits += 2 * log2(n);
double kBits = logChoose(k, k + n - 1);
double rowBits = 0.0;
for(DNode<N> node : graph.nodes())
rowBits += logChoose(node.linksIn().size(), n, 2.0); // TODO: stars and bars
Global.log().info("sizeBits: "+sizeBits+", kBits: "+kBits+", rowBits "+rowBits+". ");
return sizeBits + kBits + rowBits;
}
示例8: iterate
import nl.peterbloem.kit.Global; //导入依赖的package包/类
public void iterate()
{
// * Find the hubs
MaxObserver<Node<N>> observer = new MaxObserver<Node<N>>(k, centralityComparator);
for(int i : clust.largestCluster())
observer.observe(graph.nodes().get(i));
// * Add the hubs to the head list
for(Node<N> node : observer.elements())
{
head.add(node.index());
mask.set(node.index(), false);
}
clust = new ConnectionClustering<N>(graph, mask);
lastGCCSize = clust.clusterSize(clust.largestClusterIndex());
Global.log().info("iteration " + iterations + ": " + clust.numClusters() + " clusters.");
// * Add the non-GCC nodes to the tail list
prependNonGCCClusters(tail);
assert(head.size() + tail.size() + mask.numOnes() == graph.size());
iterations ++;
}
示例9: newNode
import nl.peterbloem.kit.Global; //导入依赖的package包/类
/**
* Add a node to the graph.
*
* Each node is added to m distinct, pre-drawn other nodes, where the
* probability of a node being drawn is proportional to its number of links.
*
* @return The new node added to the graph.
*/
public Node<String> newNode()
{
Node<String> node = graph.add(LABEL);
for(Node<String> neighbor : sample(probabilities, attach))
{
if(Global.random().nextBoolean())
node.connect(neighbor);
else
neighbor.connect(node);
probabilities.add(neighbor);
probabilities.add(node);
}
return node;
}
示例10: random
import nl.peterbloem.kit.Global; //导入依赖的package包/类
@Test
public void random()
{
for(int seed : series(3))
{
if(seed % 10 == 0)
System.out.print('.');
Global.random().setSeed(seed);
int n = Global.random().nextInt(25) + 5;
double p = Global.random().nextDouble() * 0.9 + 0.1;
DGraph<?> graph = RandomGraphs.randomDirected(n, p);
DSequenceEstimator<String> model = new DSequenceEstimator<String>(graph);
for(int i : series(100))
{
DGraph<String> gen = model.nonuniform().graph();
assertEquals(sequence(graph), sequence(gen));
}
}
}
示例11: testRemove
import nl.peterbloem.kit.Global; //导入依赖的package包/类
@Test
public void testRemove()
{
Global.randomSeed();
DGraph<String> graph = new DiskDGraph(r());
DNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null),
d = graph.add(null),
e = graph.add(null);
b.connect(a);
c.connect(a);
d.connect(a);
e.connect(a);
assertEquals(4, graph.numLinks());
assertEquals(5, graph.size());
a.remove();
assertEquals(0, graph.numLinks());
assertEquals(4, graph.size());
}
示例12: testLinks
import nl.peterbloem.kit.Global; //导入依赖的package包/类
@Test
public void testLinks()
{
Global.randomSeed();
DGraph<String> graph = new DiskDGraph(r());
DNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null);
a.connect(b);
a.connect(c);
a.connect(c);
assertEquals(0, a.links(a).size());
assertEquals(1, a.links(b).size());
assertEquals(1, b.links(a).size());
assertEquals(2, a.links(c).size());
assertEquals(2, c.links(a).size());
System.out.println(graph.links());
}
示例13: testNumLinks2
import nl.peterbloem.kit.Global; //导入依赖的package包/类
@Test
public void testNumLinks2()
{
Global.randomSeed();
DGraph<String> graph = new DiskDGraph(r());
DNode<String> a = graph.add("a");
DNode<String> b = graph.add("b");
DNode<String> c = graph.add("c");
a.connect(a);
b.connect(c);
c.connect(a);
a.connect(c);
a.connect(c);
int numLinks = 0;
for(Link<String> link : graph.links())
numLinks++;
assertEquals(5, numLinks);
assertEquals(graph.numLinks(), numLinks);
}
示例14: testRemove
import nl.peterbloem.kit.Global; //导入依赖的package包/类
@Test
public void testRemove()
{
Global.randomSeed();
UGraph<String> graph = new DiskUGraph(r());
UNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null),
d = graph.add(null),
e = graph.add(null);
b.connect(a);
c.connect(a);
d.connect(a);
e.connect(a);
assertEquals(4, graph.numLinks());
assertEquals(5, graph.size());
a.remove();
assertEquals(0, graph.numLinks());
assertEquals(4, graph.size());
}
示例15: testConnected
import nl.peterbloem.kit.Global; //导入依赖的package包/类
@Test
public void testConnected()
{
Global.randomSeed();
UGraph<String> graph = new DiskUGraph(r());
UNode<String> a = graph.add(null),
b = graph.add(null),
c = graph.add(null);
a.connect(b);
a.connect(c);
assertTrue(a.connected(b));
assertFalse(a.connected(a));
assertTrue(b.connected(a));
assertTrue(a.connected(c));
assertTrue(c.connected(a));
assertFalse(b.connected(c));
assertFalse(c.connected(b));
}