當前位置: 首頁>>代碼示例>>Java>>正文


Java Global類代碼示例

本文整理匯總了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();
}
 
開發者ID:pbloem,項目名稱:motive,代碼行數:24,代碼來源:Konect.java

示例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"));
	
}
 
開發者ID:pbloem,項目名稱:motive,代碼行數:27,代碼來源:MotifModelTest.java

示例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.");
}
 
開發者ID:pbloem,項目名稱:orca,代碼行數:24,代碼來源:OrcaTest.java

示例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;
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:19,代碼來源:MUTAG.java

示例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;
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:20,代碼來源:DSequenceEstimator.java

示例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());
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:24,代碼來源:AllSubgraphs.java

示例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;
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:19,代碼來源:BinomialRowCompressor.java

示例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 ++;
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:27,代碼來源:SlashBurn.java

示例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;
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:26,代碼來源:DBAGenerator.java

示例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));
		}
	}
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:25,代碼來源:DSequenceModelTest.java

示例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());
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:26,代碼來源:DiskDGraphTest.java

示例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());
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:24,代碼來源:DiskDGraphTest.java

示例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);
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:24,代碼來源:DiskDGraphTest.java

示例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());
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:26,代碼來源:DiskUGraphTest.java

示例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));
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:23,代碼來源:DiskUGraphTest.java


注:本文中的nl.peterbloem.kit.Global類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。