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


Java Global.randomSeed方法代碼示例

本文整理匯總了Java中nl.peterbloem.kit.Global.randomSeed方法的典型用法代碼示例。如果您正苦於以下問題:Java Global.randomSeed方法的具體用法?Java Global.randomSeed怎麽用?Java Global.randomSeed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nl.peterbloem.kit.Global的用法示例。


在下文中一共展示了Global.randomSeed方法的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: 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

示例3: 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

示例4: testLinks2

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testLinks2()
{
	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),
              		f = graph.add(null);
	
	a.connect(b);
	b.connect(c);
	c.connect(a);
	
	b.connect(e);
	c.connect(e);
	c.connect(d);
	
	e.connect(d);
	f.connect(d);
	e.connect(f);
	
	List<ULink<String>> links = new ArrayList<ULink<String>>((int)graph.numLinks());
	for(ULink<String> link : graph.links())
		links.add(link);
	
	assertEquals(9, links.size());
	
	System.out.println(graph.links());
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:34,代碼來源:DiskUGraphTest.java

示例5: testRead

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testRead() 
{
	Global.randomSeed();
	
	UTGraph<String, String> graph = RandomGraphs.preferentialAttachment(30, 2);
	
	UTGraph<String, String> out = Dot.readUT(graph.toString());
	
	System.out.println(graph);
	System.out.println(out);
	
	assertEquals(graph.size(), out.size());
	assertEquals(graph.numLinks(), out.numLinks());
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:16,代碼來源:DotTest.java

示例6: testToString

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testToString()
{
	Global.randomSeed();
	DGraph<String> graph = new DiskDGraph(r());
	
	DNode<String> a = graph.add("a"),
	              b = graph.add("b");
	graph.add("c");

	a.connect(b);
	
	System.out.println(graph);
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:15,代碼來源:DiskDGraphTest.java

示例7: testRemove2

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testRemove2()
{
	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);

	a.connect(b);
	b.connect(c);
	c.connect(d);
	d.connect(a);
			
	b.remove();
	
	assertFalse(graph.get(0).connected(graph.get(0)));
	assertFalse(graph.get(0).connected(graph.get(1)));
	assertTrue (graph.get(0).connected(graph.get(2)));
	assertFalse(graph.get(1).connected(graph.get(0)));
	assertFalse(graph.get(1).connected(graph.get(1)));
	assertTrue (graph.get(1).connected(graph.get(2)));
	assertTrue (graph.get(2).connected(graph.get(0)));
	assertTrue (graph.get(2).connected(graph.get(1)));
	assertFalse(graph.get(2).connected(graph.get(2)));
	
	System.out.println(graph);
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:31,代碼來源:DiskUGraphTest.java

示例8: testRemove2

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testRemove2()
{
	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);

	a.connect(b);
	b.connect(c);
	c.connect(d);
	d.connect(a);
			
	b.remove();
	
	assertFalse(graph.get(0).connectedTo(graph.get(0)));
	assertFalse(graph.get(0).connectedTo(graph.get(1)));
	assertFalse(graph.get(0).connectedTo(graph.get(2)));
	assertFalse(graph.get(1).connectedTo(graph.get(0)));
	assertFalse(graph.get(1).connectedTo(graph.get(1)));
	assertTrue (graph.get(1).connectedTo(graph.get(2)));
	assertTrue (graph.get(2).connectedTo(graph.get(0)));
	assertFalse(graph.get(2).connectedTo(graph.get(1)));
	assertFalse(graph.get(2).connectedTo(graph.get(2)));
	
	System.out.println(graph);
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:31,代碼來源:DiskDGraphTest.java

示例9: testConnected

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testConnected()
{
	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);
	
	assertTrue(a.connected(b));
	assertTrue(a.connectedTo(b));
	
	assertFalse(a.connected(a));
	assertFalse(a.connectedTo(a));

	assertTrue(b.connected(a));
	assertFalse(b.connectedTo(a));
	
	assertTrue(a.connected(c));
	assertTrue(a.connectedTo(c));

	assertTrue(c.connected(a));
	assertFalse(c.connectedTo(a));
	
	assertFalse(b.connected(c));
	assertFalse(b.connectedTo(c));
	
	assertFalse(c.connected(b));
	assertFalse(c.connectedTo(b));
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:35,代碼來源:DiskDGraphTest.java

示例10: testRandomSelfLoops

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testRandomSelfLoops() {
	Global.randomSeed();
	
	UTGraph<String, String> graph = RandomGraphs.random(30, 16);
	assertFalse(Graphs.hasSelfLoops(graph));
	
	System.out.println(graph);
	System.out.println(Graphs.shuffle(graph));		
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:11,代碼來源:RandomGraphsTest.java

示例11: testLinks2

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testLinks2()
{
	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),
              		f = graph.add(null);
	
	a.connect(b);
	b.connect(c);
	c.connect(a);
	
	b.connect(e);
	c.connect(e);
	c.connect(d);
	
	e.connect(d);
	f.connect(d);
	e.connect(f);
	
	List<DLink<String>> links = new ArrayList<DLink<String>>((int)graph.numLinks());
	for(DLink<String> link : graph.links())
		links.add(link);
	
	assertEquals(9, links.size());
	
	System.out.println(graph.links());
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:34,代碼來源:DiskDGraphTest.java

示例12: testEquals

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testEquals()
{
	Global.randomSeed();
	
	DGraph<String> g1 = new DiskDGraph(r());
	g1.add("a");
	g1.add("b");
	g1.add("c");
	
	g1.node("a").connect(g1.node("b"));
	g1.node("b").connect(g1.node("c"));
	
	DGraph<String> g2 = new DiskDGraph(r());
	g2.add("a");
	g2.add("b");
	g2.add("c");
	 
	g2.node("a").connect(g2.node("b"));                    
	g2.node("b").connect(g2.node("c"));		
        
	assertTrue(g1.equals(g2));
	
	g2.node("a").connect(g2.node("c"));

	assertFalse(g1.equals(g2));
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:28,代碼來源:DiskDGraphTest.java

示例13: testImportBig

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
public void testImportBig()
		throws IOException
{
	Global.randomSeed();
	DGraph<String> graph = DiskDGraph.fromFile(new File("/Users/Peter/Documents/datasets/graphs/p2p/p2p.txt"), DIR);

	System.out.println(graph.size());
	System.out.println(graph.numLinks());
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:10,代碼來源:DiskDGraphTest.java

示例14: testImport

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
/**
	 * 
	 * 
	 * @throws IOException
	 */
	@Test
	public void testImport()
			throws IOException
	{
		Global.randomSeed();

		FileIO.copy("graphs/p2p/p2p.txt", DIR);
		
		DGraph<String> diskGraph = DiskDGraph.fromFile(new File(DIR, "p2p.txt"), DIR);
		assertEquals(diskGraph.size(), new ArrayList<DNode<String>>(diskGraph.nodes()).size());
		
		List<DLink<String>> links = new ArrayList<DLink<String>>((int)diskGraph.numLinks());
		for(DLink<String> link : diskGraph.links())
			links.add(link);
		
		assertEquals(diskGraph.numLinks(), links.size());

		DGraph<String> memGraph  = Data.edgeListDirectedUnlabeled(new File(DIR, "p2p.txt"), true);
				
//		for(int i : series(memGraph.size()))
//		{
//			String a = diskGraph.get(i).out() + " " + diskGraph.get(i).in();
//			
//			String b = memGraph.get(i).out() + " " + memGraph.get(i).in();
//			
//			if(! a.equals(b))
//			{
//				System.out.println("d " + a);
//				System.out.println("m " + b);
//			}	
//		}

		assertEquals(memGraph, diskGraph);
	}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:40,代碼來源:DiskDGraphTest.java

示例15: testNodeLinks

import nl.peterbloem.kit.Global; //導入方法依賴的package包/類
@Test
public void testNodeLinks()
{
	Global.randomSeed();
	DGraph<String> graph = Examples.physicians();
	graph = DiskDGraph.copy(graph, r());

	for(Node<String> node : graph.nodes())
	{
		Collection<? extends Node<String>> nbs = node.neighbors();
					
		for(Node<String> neighbor : nbs)
			assertTrue(node.links(neighbor).size() > 0);
	}
}
 
開發者ID:Data2Semantics,項目名稱:nodes,代碼行數:16,代碼來源:DiskDGraphTest.java


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