|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.network.DegNetGenerator
public class DegNetGenerator
Generates an adjacency matrix given a mean degree, a variance, and a list of probilities. In general matrix generation works as follows:
1. Every row in matrix is randomly assigned a degree (the vector sum of the row). Each row's degree is a random number drawn from a normal distribution. The mean of this distribution is the average nodal degree specified by the user and the standard deviation of the the distribution is also specified by the user. If the assigned degree is less than 0 it is set to one. If it is greater than the maximum degree (the size of the row - 1) then it is set to the maximun.
2. An empty matrix is seeded with some X (user specifiable) number of rows. The seeding process randomly chooses X number of rows from the list of available rows. The available rows are those rows that haven't been through the random assignment process (see 3).
3. These seed rows are randomly assign a 1 to some number of cells in that row. The amount of cells to set to one is determined according to the degree of that row determined in step 1. For as many cells need to be set to one, the actual individual cell to set is randomly determined through a uniform distribution. No cell is set twice and the diagonal is excluded. The individualy chosen cell is then set to one.
4. New rows are then created on the basis of the cell values created in step 3. These values are created according to some user specified probability. If the matrix is to be symmetric (not a digraph) then the probability is 1.0. The general idea here is to determine whether the links randomly created in step 3. go both ways. So for example, if after step 3 the matrix looks like:
A B C
A 0 0 0
B 1 0 1
C 0 0 0
a link will be created from A to B, and from C to B with some
specified probability. The new rows corresponding to the nodes that
are the source of these new links are then used in step 6. For example,
if a link is created from A to B, row A will then be used in step 6.Note that links are only created in a row if the current row sum for that row is less than the intended degree for that row as determined in step 1. However, if the matrix is to be made symmetric, it is made so and the row sums are ignored.
5. New links are then created using the powers of the matrix that
results from step 4. These links are created according to user
specified probablilities corresponding to the path length (powers).
The exact formula is as follows:
As in step 4., no links are created if the current row sum for a row is
greater than intended row sum. This holds both for symmetric and
directed matrices. If the matrix is to be symmetric then
this condition must hold for both nodes.
6. The list of rows created in step 4. undergo the random assignment
process described in step 3. If the sum of the row is greater than the
number of random links to be created then no assignment will occur.
if
(i_intended_vec_sum / avgDensity) * (((matrix_size / avgDensity) *
(1 - Sum(probs[n]))) + (probs[0] * matrix^2_ij) +
(probs[1] * powArray^3_ij) + ... + (probs[n] * powArray^n_ij))
>= uniform_float_from_1_to_0
then
there is a link
where:
i_intended_vec_sum = the intended row sum as determined in step 1.
avgDensity = the user specified mean degree
probs[] = an array of probilities that specify the likelyhood of
one node having a link to another. This array is indexed to the
various matrix powers such that the first probility refers to the
likelyhood of one node having a link to another if that node is
a walk of length 2 away, and so on for the other powers.
7. Step 4. is then repeated using the list of rows from step 6. in place of the seeded rows. Only those cells actually assigned in step 6. will be used in step 3. If step 6. fails to generate any new cells (that is, column vals whose corresponding row can be used in step 3), then new seeded rows are generated as in step 2.
8. Steps 3.- 7 are repeated until all of the rows in the matrix have undergone the random link assignment described in step 3.
Each row should undergo random link assignment once and only once. Rows that undergo random link assignment in the same iteration and refer to each other will not get those links created. So for example, if rows C and A have just been randomly assigned links, such that:
A B C
A 0 1 1
B 0 0 0
C 0 1 0
A link from C -> A will not be created. This assumes of course that
the matrix is not symmetrical.The getMatrix method takes three arguments: the number of rows to seed, an array of probabilities, and whether this is a directed graph or not. The number of rows to seed determines the initial number of rows to seed and the number of rows to seed when there are no new rows to work with from a previous seed (as described in step 7). The first member of the probabilities array is a float between 0 and 1.0 that determine the probabilities mentioned in step 3 (i.e. the probability that if A -> B then B -> A). The remaining probabilities refer to the power probilities - the second member of the array is the probiblities the some node will know another node 2 links away, and so on for the remaining members of the array (i.e. the third member is for three links away). The last argument determines wether the matrix is directed or not. If not then it is symmetric and the first member of the probilities array is ignored as if A -> B then B -> A.
Note: This class is still in beta and should only be used in order to test it.
| Constructor Summary | |
|---|---|
DegNetGenerator(int degree,
float variance,
int size)
|
|
| Method Summary | |
|---|---|
AdjacencyMatrix |
getMatrix(int numRowsToSeed,
float[] edgeProbability,
boolean isDigraph)
Returns a random matrix generated using the specified parameters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DegNetGenerator(int degree,
float variance,
int size)
| Method Detail |
|---|
public AdjacencyMatrix getMatrix(int numRowsToSeed,
float[] edgeProbability,
boolean isDigraph)
numRowsToSeed - the number of rows to seededgeProbability - the probability ...
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||