### minor optimization in household graph generation

parent c995d9f4
 ... @@ -33,8 +33,6 @@ Also returns a vector of AgentDemographic representing each agent, defined by th ... @@ -33,8 +33,6 @@ Also returns a vector of AgentDemographic representing each agent, defined by th total_household_pop = sum(sum.(households_composition)) total_household_pop = sum(sum.(households_composition)) population_list = Vector{AgentDemographic}(undef,total_household_pop) population_list = Vector{AgentDemographic}(undef,total_household_pop) wg = WeightedGraph(total_household_pop,sampler_matrix) wg = WeightedGraph(total_household_pop,sampler_matrix) # test_graph_1 = SimpleGraph(total_household_pop) # test_graph_2 = SimpleGraph(total_household_pop) vertex_pointer = 1 vertex_pointer = 1 for household in households_composition for household in households_composition num_vertices = sum(household) num_vertices = sum(household) ... @@ -43,22 +41,14 @@ Also returns a vector of AgentDemographic representing each agent, defined by th ... @@ -43,22 +41,14 @@ Also returns a vector of AgentDemographic representing each agent, defined by th @inbounds population_list[vertex_pointer+household_pointer:vertex_pointer+household_pointer+size-1] .= AgentDemographic(k) @inbounds population_list[vertex_pointer+household_pointer:vertex_pointer+household_pointer+size-1] .= AgentDemographic(k) household_pointer += size household_pointer += size end end for v in vertex_pointer:(vertex_pointer + num_vertices - 1), w in vertex_pointer:(vertex_pointer + num_vertices - 1) for v in vertex_pointer:(vertex_pointer + num_vertices - 1), w in vertex_pointer:v if v != w if v != w weight::UInt8 = rand(Random.default_rng(Threads.threadid()),sampler_matrix[Int(population_list[v]),Int(population_list[w])]) weight::UInt8 = rand(Random.default_rng(Threads.threadid()),sampler_matrix[Int(population_list[v]),Int(population_list[w])]) add_edge!(wg,v,w,weight) add_edge!(wg,v,w,weight) # add_edge!(test_graph_1,v,w) end end end end # for v in vertex_pointer:(vertex_pointer + num_vertices - 1), w in vertex_pointer:(vertex_pointer + num_vertices - 1) # if v != w # weight::UInt8 = rand(Random.default_rng(Threads.threadid()),sampler_matrix[Int(population_list[v]),Int(population_list[w])]) # add_edge!(test_graph_2,v,w) # end # end vertex_pointer+=num_vertices vertex_pointer+=num_vertices end end # display((test_graph.ne,ne(wg))) return wg,population_list return wg,population_list end end ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!