Changeset 594 for mds-and-trees


Ignore:
Timestamp:
08/23/16 18:13:31 (8 years ago)
Author:
konrad
Message:

Fixed drawing the spine and the skeleton for the tree-genealogy.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mds-and-trees/tree-genealogy.py

    r589 r594  
    6565    from_col = [100, 70, 0]
    6666    to_col = [60, 0, 0]
    67     from_col = [0, 0, 0]
    68     to_col = [80, 0, 80]
    6967    # lava
    7068    # from_col = [100, 80, 0]
     
    295293            dot_style = svg_clear_dot_style #svg_generate_dot_style(depth[c]/max_depth)
    296294        svg_add_dot( (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), dot_style)
     295        #svg_add_text( str(depth[c]), (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), "end")
    297296def draw_children():
    298297    global visited
     
    314313
    315314def draw_spine_recurrent(node):
     315    global visited
    316316    for c in inv_nodes[node]:
     317
     318        # we want to draw the node just once
     319        if all_parents_visited(c):
     320            visited[c] = True
     321
     322            if depth[c] == depth[node] - 1:
     323                if c in inv_nodes:
     324                    draw_spine_recurrent(c)
     325
    317326        if depth[c] == depth[node] - 1:
    318             if c in inv_nodes:
    319                 draw_spine_recurrent(c)
    320 
    321327            line_style = svg_spine_line_style
    322328            svg_add_line( (w_margin+w_no_margs*(positions[node][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[node][1]/max_height),
    323329                (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), line_style)
    324             #svg_add_dot( (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), svg_spine_dot_style)
     330        #svg_add_dot( (w_margin+w_no_margs*(positions[c][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[c][1]/max_height), svg_spine_dot_style)
    325331def draw_spine():
     332    global visited
     333    visited = {}
     334    visited[firstnode] = True
     335
    326336    draw_spine_recurrent(firstnode)
    327337    #svg_add_dot( (w_margin+w_no_margs*(positions[firstnode][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[firstnode][1]/max_height), svg_spine_dot_style)
    328338
    329 def draw_skeleton_reccurent(node, max_depth):
     339def draw_skeleton_reccurent(node):
     340    global visited
    330341    for c in inv_nodes[node]:
    331         if depth[c] >= min_skeleton_depth or depth[c] == max([depth[q] for q in inv_nodes[node]]):
    332             if c in inv_nodes:
    333                 draw_skeleton_reccurent(c, max_depth)
    334 
     342
     343        if all_parents_visited(c):
     344            visited[c] = True
     345
     346            if depth[c] >= min_skeleton_depth: # or depth[c] == max([depth[q] for q in inv_nodes[node]]):
     347                if c in inv_nodes:
     348                    draw_skeleton_reccurent(c)
     349
     350        if depth[c] >= min_skeleton_depth: # or depth[c] == max([depth[q] for q in inv_nodes[node]]):
     351            #print([depth[q] for q in inv_nodes[node]])
    335352            line_style = svg_spine_line_style
    336353            svg_add_line( (w_margin+w_no_margs*(positions[node][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[node][1]/max_height),
     
    339356            #             svg_spine_dot_style)
    340357def draw_skeleton():
    341     max_depth = 0
    342     for k, v in depth.items():
    343             max_depth = max(max_depth, v)
    344 
    345     draw_skeleton_reccurent(firstnode, max_depth)
     358    global visited
     359    visited = {}
     360    visited[firstnode] = True
     361
     362    draw_skeleton_reccurent(firstnode)
    346363    #svg_add_dot( (w_margin+w_no_margs*(positions[firstnode][0]-min_width)/(max_width-min_width), h_margin+h_no_margs*positions[firstnode][1]/max_height),
    347364    #             svg_spine_dot_style)
Note: See TracChangeset for help on using the changeset viewer.