Changeset - 394cafce8d31
[Not reviewed]
default
0 1 0
Mads Kiilerich - 12 years ago 2013-12-10 19:30:37
madski@unity3d.com
graph: if the child has multiple parents then use the parents color - also when close to the child
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/graphmod.py
Show inline comments
 
@@ -86,55 +86,55 @@ def _colored(dag):
 

	
 
      - Tuple (col, color) with column and color index for the current node
 
      - A list of tuples indicating the edges between the current node and its
 
        parents.
 
    """
 
    seen = []
 
    colors = {}
 
    newcolor = 1
 

	
 
    getconf = lambda rev: {}
 

	
 
    for (cur, type, data, parents) in dag:
 

	
 
        # Compute seen and next
 
        if cur not in seen:
 
            seen.append(cur)  # new head
 
            colors[cur] = newcolor
 
            newcolor += 1
 

	
 
        col = seen.index(cur)
 
        color = colors.pop(cur)
 
        next = seen[:]
 

	
 
        # Add parents to next
 
        addparents = [p for p in parents if p not in next]
 
        next[col:col + 1] = addparents
 

	
 
        # Set colors for the parents
 
        for i, p in enumerate(addparents):
 
            if not i:
 
                colors[p] = color
 
            else:
 
                colors[p] = newcolor
 
                newcolor += 1
 

	
 
        # Add edges to the graph
 
        edges = []
 
        for ecol, eid in enumerate(seen):
 
            if eid in next:
 
                bconf = getconf(eid)
 
                edges.append((
 
                    ecol, next.index(eid), colors[eid],
 
                    bconf.get('width', -1),
 
                    bconf.get('color', '')))
 
            elif eid == cur:
 
                for p in parents:
 
                    bconf = getconf(p)
 
                    edges.append((
 
                        ecol, next.index(p), color,
 
                        ecol, next.index(p), colors[p] if len(parents) > 1 else color,
 
                        bconf.get('width', -1),
 
                        bconf.get('color', '')))
 

	
 
        # Yield and move on
 
        yield (cur, type, data, (col, color), edges)
 
        seen = next
0 comments (0 inline, 0 general)