## Define edge properties: from, to, rate, and count.
edges <- data.frame(
from = c(2, 3, 4, 1, 4, 5, 1, 3, 1, 3),
to = c(1, 1, 1, 2, 3, 3, 4, 4, 5, 5),
rate = c(0.2, 0.01, 0.79, 1, 0.2, 0.05, 0.2, 0.8, 0.2, 0.8),
count = c(5, 5, 5, 50, 10, 10, 5, 5, 5, 5)
)
## Convert to matrix for 6 nodes.
mat <- edge_properties_to_matrix(edges, 6)
print(mat)
## Interpretation of Column 1 (to node 1): The column contains a
## single sequence of 3 blocks (edges from # 2, 3, and 4).
## Row 1: Index of 'from' node 2 (2-1 = 1).
## Row 2: rate=0.2
## Row 3: count=5
## Row 4: Index of 'from' node 3 (3-1 = 2).
## Row 5: rate=0.01
## Row 6: count=5
## Row 7: Index of 'from' node 4 (4-1 = 3).
## Row 8: rate=0.79
## Row 9: count=5
## Row 10: Stop marker (-1) indicating the end of the list for node 1.
Run the code above in your browser using DataLab