refactored rels.py and directed.py to generate self-sufficient html