Create a Harris Matrix from archaeological stratigraphy data using Python and Graphviz. See the Harris Matrix Data Package for a revised and updated version
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.1 KiB

#! /usr/bin/env python
# -*- coding: utf-8 -*-
from pygraphviz import *
class basicGraph:
'''Takes a list with proper values and builds a graph.'''
def __init__(self,graph_data):
self.A = AGraph(directed=True)
self.graph_data = graph_data
def create_graph(self,graph_data):
gr2 = []
for i in graph_data:
if i[2] == 'a': # after
gr2.append((i[0], i[1]))
elif i[2] == 'b': # before
gr2.append((i[1], i[0]))
elif i[2] == 'c': # contemporary
sb = self.A.add_subgraph()
sb.graph_attr['rank'] = 'same'
sb.add_edge(i[0],i[1], dir='none')
def draw(self,output,format='png'):
B=self.A.tred(copy=True) # remove redundant relations
C=B.acyclic(copy=True) # make sure there are no cyclic relations
C.draw(output, prog='dot', format='png')