- /**
- * The value of the node.
- **/
- double value;
- /**
- * The next node in the list.
- **/
- protected Node next;
- /**
- * Array of nodes to which we send our value.
- **/
- Node[] toNodes;
- /**
- * Array of nodes from which we receive values.
- **/
- Node[] fromNodes;
- /**
- * Coefficients on the fromNodes edges
- **/
- double[] coeffs;
- /**
- * The number of fromNodes edges
- **/
- int fromCount;
- /**
- * Used to create the fromEdges - keeps track of the number of edges that have
- * been added
- **/
- int fromLength;
-
- public Node() {
-
- }
-
- /**
- * Constructor for a node with given `degree'. The value of the
- * node is initialized to a random value.
- **/
- public Node(int degree, Random r)
- {
- value = r.nextDouble();
- // create empty array for holding toNodes
- toNodes = global new Node[degree];
-
- next = null;
- for (int i = 0; i<fromCount; i++) {
- fromNodes[i] = null;
- coeffs[i] = 0.0;
- }
- fromCount = 0;
- fromLength = 0;
- }
-
- /**
- * Create the linked list of E or H nodes. We create a table which is used
- * later to create links among the nodes.
- * @param size the no. of nodes to create
- * @param degree the out degree of each node
- * @return a table containing all the nodes.
- **/
- public static Node[] fillTable(int size, int degree, Random r)
- {
- Node[] table = global new Node[size];
-
- Node prevNode = global new Node(degree, r);
- table[0] = prevNode;
- for (int i = 1; i < size; i++) {
- Node curNode = global new Node(degree, r);
- table[i] = curNode;
- prevNode.next = curNode;
- prevNode = curNode;
- }
- return table;
- }
-
- /**
- * Create unique `degree' neighbors from the nodes given in nodeTable.
- * We do this by selecting a random node from the give nodeTable to
- * be neighbor. If this neighbor has been previously selected, then
- * a different random neighbor is chosen.
- * @param nodeTable the list of nodes to choose from.
- **/
- public void makeUniqueNeighbors(Node[] nodeTable, Random rand)
- {
- for (int filled = 0; filled < toNodes.length; filled++) {
- int k;
- Node otherNode;
- boolean isBreak;
-
- do {
- isBreak = false;
- // generate a random number in the correct range
- int index = rand.nextInt();
- if (index < 0) index = -index;
- index = index % nodeTable.length;
-
- // find a node with the random index in the given table
- otherNode = nodeTable[index];
-
- for (k = 0; (k < filled) && (isBreak==false); k++) {
- if (otherNode == toNodes[filled])
- isBreak = true;
- //break;
- }
- } while (k < filled);
-
- // other node is definitely unique among "filled" toNodes
- toNodes[filled] = otherNode;
-
- // update fromCount for the other node
- otherNode.fromCount++;
- }
+ /**
+ * The value of the node.
+ **/
+ double value;
+ /**
+ * The next node in the list.
+ **/
+ protected Node next;
+ /**
+ * Array of nodes to which we send our value.
+ **/
+ Node[] toNodes;
+ /**
+ * Array of nodes from which we receive values.
+ **/
+ Node[] fromNodes;
+ /**
+ * Coefficients on the fromNodes edges
+ **/
+ double[] coeffs;
+ /**
+ * The number of fromNodes edges
+ **/
+ int fromCount;
+ /**
+ * Used to create the fromEdges - keeps track of the number of edges that have
+ * been added
+ **/
+ int fromLength;
+
+ /**
+ * Constructor for a node with given `degree'. The value of the
+ * node is initialized to a random value.
+ **/
+ public Node(int degree, Random r)
+ {
+ value = r.nextDouble();
+ // create empty array for holding toNodes
+ toNodes = global new Node[degree];
+ }
+
+ /**
+ * Create the linked list of E or H nodes. We create a table which is used
+ * later to create links among the nodes.
+ * @param size the no. of nodes to create
+ * @param degree the out degree of each node
+ * @return a table containing all the nodes.
+ **/
+ public static Node[] fillTable(int size, int degree, Random r)
+ {
+ Node[] table;
+ Node prevNode;
+ table = global new Node[size];
+ prevNode = global new Node(degree, r);
+ table[0] = prevNode;
+ for (int i = 1; i < size; i++) {
+ Node curNode = global new Node(degree, r);
+ table[i] = curNode;
+ prevNode.next = curNode;
+ prevNode = curNode;