Rotating graph orientation.
This commit is contained in:
parent
175e09f167
commit
1f6b6b6c62
2 changed files with 82 additions and 70 deletions
|
@ -40,15 +40,12 @@ module Network
|
|||
def index_commits
|
||||
days = []
|
||||
@map = {}
|
||||
@reserved = {}
|
||||
|
||||
@commits.reverse.each_with_index do |c,i|
|
||||
@commits.each_with_index do |c,i|
|
||||
c.time = i
|
||||
days[i] = c.committed_date
|
||||
@map[c.id] = c
|
||||
end
|
||||
|
||||
@reserved = {}
|
||||
days.each_index do |i|
|
||||
@reserved[i] = []
|
||||
end
|
||||
|
||||
|
@ -135,11 +132,7 @@ module Network
|
|||
spaces = []
|
||||
|
||||
commit.parents(@map).each do |parent|
|
||||
range = if commit.time < parent.time then
|
||||
commit.time..parent.time
|
||||
else
|
||||
parent.time..commit.time
|
||||
end
|
||||
range = commit.time..parent.time
|
||||
|
||||
space = if commit.space >= parent.space then
|
||||
find_free_parent_space(range, parent.space, -1, commit.space)
|
||||
|
@ -166,7 +159,7 @@ module Network
|
|||
range.each do |i|
|
||||
if i != range.first &&
|
||||
i != range.last &&
|
||||
@commits[reversed_index(i)].spaces.include?(overlap_space) then
|
||||
@commits[i].spaces.include?(overlap_space) then
|
||||
|
||||
return true;
|
||||
end
|
||||
|
@ -184,7 +177,7 @@ module Network
|
|||
return
|
||||
end
|
||||
|
||||
time_range = leaves.last.time..leaves.first.time
|
||||
time_range = leaves.first.time..leaves.last.time
|
||||
space_base = get_space_base(leaves)
|
||||
space = find_free_space(time_range, 2, space_base)
|
||||
leaves.each do |l|
|
||||
|
@ -198,17 +191,17 @@ module Network
|
|||
end
|
||||
|
||||
# and mark it as reserved
|
||||
min_time = leaves.last.time
|
||||
leaves.last.parents(@map).each do |parent|
|
||||
if parent.time < min_time
|
||||
min_time = parent.time
|
||||
end
|
||||
if parent_time.nil?
|
||||
min_time = leaves.first.time
|
||||
else
|
||||
min_time = parent_time + 1
|
||||
end
|
||||
|
||||
if parent_time.nil?
|
||||
max_time = leaves.first.time
|
||||
else
|
||||
max_time = parent_time - 1
|
||||
max_time = leaves.last.time
|
||||
leaves.last.parents(@map).each do |parent|
|
||||
if max_time < parent.time
|
||||
max_time = parent.time
|
||||
end
|
||||
end
|
||||
mark_reserved(min_time..max_time, space)
|
||||
|
||||
|
@ -289,9 +282,5 @@ module Network
|
|||
end
|
||||
refs_cache
|
||||
end
|
||||
|
||||
def reversed_index(index)
|
||||
-index - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue