Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
204 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
|
||
|
||
# Compile # | ||
|
||
```g++ time_graph_gen.cc -o time_graph_gen -O3``` | ||
|
||
|
||
# Usage # | ||
|
||
|
||
```./time_graph_gen <Path to graph in DIMACS 9th gr format> <Temporal Degree> <Max Time> <Path to Output file>``` | ||
|
||
```./time_graph_gen ~/hetro_map_graphs/USA-road-t.CAL.gr 10 1895126 CAL_t.gr``` | ||
|
0
time_graph_gen.cc → C Code/time_graph_gen.cc
100755 → 100644
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
|
||
|
||
|
||
# Compile # | ||
# Run Python Script # | ||
|
||
```g++ time_graph_gen.cc -o time_graph_gen -O3``` | ||
```python gen_time_graph.py``` | ||
|
||
|
||
# Usage # | ||
# Configurations # | ||
|
||
time_helper.py contains the configurations | ||
|
||
|
||
``` | ||
static_graph => Path to static graph file in gr format (9th DIMACS) | ||
``` | ||
|
||
```./time_graph_gen <Path to graph in DIMACS 9th gr format> <Temporal Degree> <Max Time> <Path to Output file>``` | ||
|
||
```./time_graph_gen ~/hetro_map_graphs/USA-road-t.CAL.gr 10 1895126 CAL_t.gr``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
import os | ||
import sys | ||
from time_helper import * | ||
|
||
from random import seed | ||
from random import randint | ||
|
||
static_graph_file = open(static_graph,"r") | ||
lines = static_graph_file.read().split("\n") | ||
static_graph_file.close() | ||
|
||
seed(1) | ||
|
||
temporal_list = [] | ||
for line in lines: | ||
if "p" in line: | ||
nodes = line.split(" ")[2] | ||
continue | ||
parts = line.split(" ") | ||
if len(parts) != 4: | ||
break | ||
node = parts[1] | ||
weight = parts[3] | ||
for t in range(0,temporal_edges,time_step): | ||
weight = int(weight) * sample_from_distribution(int(node),int(t)) | ||
temporal_edge = parts[0] + " " + parts[1] + " " + parts[2] + " " + str(int(round(weight))) + " " + str(t) | ||
if randint(0, 100) > p: | ||
temporal_list = temporal_list + [temporal_edge] | ||
|
||
temporal_graph_file = open(temporal_graph,"w") | ||
temporal_graph_file.write("p sp " + nodes + " " + str(len(temporal_list)) + "\n") | ||
for line in temporal_list: | ||
temporal_graph_file.write(line + "\n") | ||
temporal_graph_file.close() | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
p sp 8 9 | ||
a 1 2 21 | ||
a 1 3073 26 | ||
a 1 4097 10 | ||
a 1 8192 13 | ||
a 2 1 39 | ||
a 2 2 910 | ||
a 2 3072 26 | ||
a 2 4097 10 | ||
a 2 6144 13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
p sp 8 82 | ||
a 1 2 162 0 | ||
a 1 2 1497 1 | ||
a 1 2 892 2 | ||
a 1 2 5876 3 | ||
a 1 2 43138 4 | ||
a 1 2 154547 5 | ||
a 1 2 1171732 6 | ||
a 1 2 23648537 7 | ||
a 1 2 307075565 8 | ||
a 1 3073 89 0 | ||
a 1 3073 662 1 | ||
a 1 3073 7430 2 | ||
a 1 3073 121753 4 | ||
a 1 3073 1496565 5 | ||
a 1 3073 4139387 6 | ||
a 1 3073 11463125 7 | ||
a 1 3073 2602998 8 | ||
a 1 4097 505 1 | ||
a 1 4097 4711 2 | ||
a 1 4097 72184 3 | ||
a 1 4097 541471 4 | ||
a 1 4097 320208 5 | ||
a 1 4097 29736323 7 | ||
a 1 4097 240612285 8 | ||
a 1 4097 1052248616 9 | ||
a 1 8192 137 0 | ||
a 1 8192 51 1 | ||
a 1 8192 758 2 | ||
a 1 8192 6903 3 | ||
a 1 8192 45893 4 | ||
a 1 8192 609626 6 | ||
a 1 8192 2677545 7 | ||
a 1 8192 22403455 8 | ||
a 1 8192 281286605 9 | ||
a 2 1 185 0 | ||
a 2 1 567 1 | ||
a 2 1 4741 2 | ||
a 2 1 24216 3 | ||
a 2 1 176012 4 | ||
a 2 1 838908 5 | ||
a 2 1 2889797 6 | ||
a 2 1 3945506 7 | ||
a 2 1 25173425 8 | ||
a 2 1 121471931 9 | ||
a 2 2 3994 0 | ||
a 2 2 36173 1 | ||
a 2 2 186216 2 | ||
a 2 2 3740018 3 | ||
a 2 2 9640936 4 | ||
a 2 2 64214242 5 | ||
a 2 2 4732455298 7 | ||
a 2 2 11445694958 8 | ||
a 2 2 80345625851 9 | ||
a 2 3072 210 0 | ||
a 2 3072 3242 1 | ||
a 2 3072 20929 2 | ||
a 2 3072 201289 3 | ||
a 2 3072 896423 4 | ||
a 2 3072 1851134 5 | ||
a 2 3072 1087289 6 | ||
a 2 3072 8826612 7 | ||
a 2 3072 44491087 8 | ||
a 2 3072 613050415 9 | ||
a 2 4097 122 0 | ||
a 2 4097 2493 2 | ||
a 2 4097 27564 3 | ||
a 2 4097 699216 4 | ||
a 2 4097 9112680 5 | ||
a 2 4097 27046751 6 | ||
a 2 4097 28459546 7 | ||
a 2 4097 94628187 8 | ||
a 2 4097 1320857947 9 | ||
a 2 6144 148 0 | ||
a 2 6144 1192 1 | ||
a 2 6144 10495 2 | ||
a 2 6144 39838 3 | ||
a 2 6144 402759 4 | ||
a 2 6144 5484850 5 | ||
a 2 6144 62552079 6 | ||
a 2 6144 693220773 7 | ||
a 2 6144 7609802827 8 | ||
a 2 6144 31675967567 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
import numpy as np | ||
|
||
static_graph = "sample.gr" | ||
temporal_graph = "sample_t.gr" | ||
time_step = 1 | ||
temporal_edges = 10 | ||
spatial_partition = 2 | ||
temporal_partition = 2 | ||
p = 3 | ||
|
||
def prob_distribution_1(): | ||
mu, sigma = 0, 10 | ||
return np.random.normal(mu, sigma) | ||
|
||
|
||
def prob_distribution_2(): | ||
mu, sigma = 0, 8 | ||
return np.random.normal(mu, sigma) | ||
|
||
def prob_distribution_3(): | ||
mu, sigma = 0, 9 | ||
return np.random.normal(mu, sigma) | ||
|
||
|
||
def prob_distribution_4(): | ||
mu, sigma = 0, 8 | ||
return np.random.normal(mu, sigma) | ||
|
||
|
||
prob_distributions = [prob_distribution_1, prob_distribution_2, prob_distribution_3, prob_distribution_4] | ||
|
||
def get_node_set(node): | ||
return node % spatial_partition | ||
|
||
def get_time_set(time_instant): | ||
return time_instant % temporal_partition | ||
|
||
def custom_distribution(node, time_instant): | ||
s = get_node_set(node) | ||
t = get_time_set(time_instant) | ||
index = s*spatial_partition + t | ||
return np.abs(prob_distributions[index]()) | ||
|
||
sample_from_distribution = custom_distribution | ||
#print(sample_from_distribution(1,1)) |