chiark / gitweb /
faff with graphs and searching
[familyTree.git] / cgiFiles / make_dot.py
index 9c9e20b157cf9d218c7e453116bbf5993aa25bd5..8006a79b636b1d32f6f2ed73087a505f1f0316a0 100755 (executable)
@@ -60,22 +60,21 @@ def add_marriage(n1,n2,children,joinChildren):
 
        if len(children)>0 and joinChildren==1:
                cNode = jN + 'c'
-               e = [cNode,children[0]]
-               if has_node(cNode):
-                       tcNode = cNode + children[0]
-                       if len(cNodes[cNode])>0:
-                               last = cNodes[cNode][-1]
-                       else:
-                               last = cNode
-                       add_spot(tcNode)
-                       cNodes[cNode].append(tcNode)
-                       add_no_arrow(last,tcNode)
-                       add_subgraph([tcNode,cNode])
+               tcNode = cNode + children[0]
+               
+               if cNodes.has_key(cNode):
+                       if not has_node(tcNode):
+                               if len(cNodes[cNode])>0:
+                                       last = cNodes[cNode][-1]
+                               add_spot(tcNode)
+                               cNodes[cNode].append(tcNode)
+                               add_no_arrow(last,tcNode)
+                               add_subgraph([tcNode,last])
                else:
-                       tcNode = cNode
-                       add_spot(cNode)
-                       cNodes[cNode] = []
-                       add_no_arrow(jN,cNode)
+                       add_spot(tcNode)
+                       cNodes[cNode] = [tcNode]
+                       add_no_arrow(jN,tcNode)
+
 
        elif len(children)>0:
                tcNode = jN
@@ -108,7 +107,7 @@ def end_dot():
        global dot
         dot = dot + "}"
 
-def start_dot():
+def start_dot(fs):
        global dot
        global nodes
        global edges
@@ -120,7 +119,7 @@ def start_dot():
        dot = "digraph G{\n"
        dot = dot + "ranksep = 0.5 nodesep = 0\n"
        subgraphs=[]
-       set_attr()
+       set_attr(fs)
 
 def add_highlight(name):
        add_node(name,highlight_attr)
@@ -132,7 +131,7 @@ def add_spot(name):
        add_node(name,spot_attr)
 
 
-def set_attr():
+def set_attr(fs):
        global person_attr
         global highlight_attr
         global spot_attr
@@ -144,7 +143,7 @@ def set_attr():
        global debug_attr
        global debug_edge_attr
        zero_size = [('width','0'),('height','0')]
-        person_attr = [('fontsize','8'),('shape','plaintext')] + zero_size
+        person_attr = [('fontsize',str(fs)),('shape','plaintext')] + zero_size
        highlight_attr = person_attr + \
                [('fontcolor','red'),('shape','box'),('color','red')]
        debug_attr = person_attr + [('fontcolor','green')]