diff --git a/README.md b/README.md new file mode 100644 index 0000000..999f5a3 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ + +# Puudot + +## Development + +Start implementing graph.py with Graphviz Python library. + +New architecture for creating dot. No clusters; one node contains one row table with each column for a person. +~~~ +dot.node('', fr'{() }|...') +dot.edge(':', '') +~~~ + +algorithm: +~~~ + for block in blocks + create node + if block has link, set link as id + else create id + add texts to node + for text in block save links + + create edges from links +~~~ diff --git a/code/new_graph.py b/code/new_graph.py new file mode 100644 index 0000000..2d3fb5b --- /dev/null +++ b/code/new_graph.py @@ -0,0 +1,41 @@ +import graphviz + +class Graph: + def __init__(self): + self.dot = None + self.edges = [] + self.node_counter = 0 + + def create_graph(self, config, data): + # TODO: process config, use for graph init + self.dot = graphviz.Graph() + + blocks = data.get('blocks', []) + for block in blocks: + self.node_counter += 1 + + # Create node id + node_id = f'f{self.node_counter}' + links = block.get('links', []) + if len(links) > 0: + node_id = f'{links[0]}' + + # Create text table for node + texts = [] + for text in block.get('texts', []): + person = text.get('text', '') + link = text.get('links', []) + if len(link) > 0: + person = f'<{link[0]}> {person}' + self.edges.append((link[0], f'{node_id}:{link[0]}')) + texts.append(person) + + # Add node + table = "|".join(texts) + self.dot.node(node_id, fr'{table}') + + # Add edges + self.dot.edges(self.edges) + + def __str__(self): + return self.dot.source \ No newline at end of file diff --git a/data/styrman-blocks.yml b/data/styrman-blocks.yml index d558fa1..0cf943b 100644 --- a/data/styrman-blocks.yml +++ b/data/styrman-blocks.yml @@ -1660,6 +1660,11 @@ blocks: label: 8. sukupolvi, Antti Jokisen lapset links: [54] texts: + - text: | + Tapio Juhani + Jokinen + s.20.04.1975 + k. - text: | Sanna Maaria Jokinen @@ -1670,11 +1675,6 @@ blocks: Jääskeläinen s. k. - - text: | - Tapio Juhani - Jokinen - s.20.04.1975 - k. - layer: 8 label: 8. sukupolvi, Maija-Liisa Jokisen lapset links: [55]