Example #1
0
		public void connect (Node _n1, Node _n2, Node _n3, Node _n4)
		{
			n1 = _n1;
			n2 = _n2;
			n3 = _n3;
			n4 = _n4;
		}
Example #2
0
		public static Node randomGraph (int size, Random r)
		{
			Node[] nodes = new Node [size];
			for (int i = 0; i < size; ++i)
				nodes [i] = new Node ();
			for (int i = 0; i < size; ++i)
				connectNode (nodes [i], nodes, r);
			return nodes [0];
		}
Example #3
0
		static void connectNode (Node n, Node[] nodes, Random r)
		{
			int size = nodes.Length;
			n.connect (nodes [r.Next (size)],
				nodes [r.Next (size)],
				nodes [r.Next (size)],
				nodes [r.Next (size)]
			);
		}
Example #4
0
		public static Node otherRandomGraph (int size, int bufsize, Random r)
		{
			int i;
			Node[] buffer = new Node [bufsize];
			Node n = null;

			for (i = 0; i < bufsize; ++i)
				n = buffer [i] = new Node ();
			for (i = 0; i < bufsize; ++i)
				connectNode (buffer [i], buffer, r);
			for (; i < size; ++i) {
				n = new Node ();
				int j = r.Next (bufsize);
				buffer [j] = n;
				connectNode (n, buffer, r);
			}
			/* in case of pinning */
			for (i = 0; i < bufsize; ++i)
				buffer [i] = null;
			return n;
		}