Skip to content

Commit

Permalink
changed way of generating contact times for random graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
josura committed Aug 23, 2024
1 parent 29ac883 commit 4c68da0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/R/euroHPC/createInputsSpeedupAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ library(readr)

# update when using a different number of inter-type iterations
max_number_of_iteration <- 100
max_time <- 20

# Function to generate a graph with preferential attachment rule, and random edge weights from 0 to 1
generate_graph_barabasi <- function(num_nodes, m) {
Expand Down Expand Up @@ -101,6 +102,11 @@ plot_graph <- function(graph, node_conditions) {
)
}

# generate a list of real numbers in the range [min, max] n times
generate_random_numbers <- function(n, min, max) {
return(runif(n, min, max))
}

# Create the input graphs for single types(communities) and create file for interactions between communities
# The interaction file should have the following format:
# startType startNodeName endType endNodeName weight
Expand Down Expand Up @@ -188,7 +194,8 @@ create_input_graphs <- function(graph, node_conditions, community_data, output_d
if(nrow(edges_between_communities) > 0){
for (i in 1:nrow(edges_between_communities)){
number_of_contacts <- sample(1:max_number_of_iteration, 1)
contact_times_column[[i]] <- paste(sample(0:(max_number_of_iteration-1), number_of_contacts), collapse = ",")
#contact_times_column[[i]] <- paste(sample(0:(max_number_of_iteration-1), number_of_contacts), collapse = ",")
contact_times_column[[i]] <- paste(generate_random_numbers(number_of_contacts, 0, max_time), collapse = ",")
}
}

Expand Down

0 comments on commit 4c68da0

Please sign in to comment.