Are there libraries or certain "techniques" that you can use to create an ontology of elements?
Or "design patterns"?
I am talking about just a "graph" of things. Suppose I have a bunch of words. Certain words are "under" other words or "related" to other words. I need a good way to group them and know their relationship.
You can use rdflib for storing triples. You then have to make your own decisions about the kind of ontology you want to build. Look at the OWL format for that.
I toyed with python and ontologies during my PhD, so perhaps a quick scan through my thesis can give you some ideas. For instance a short OWL summary or a UML model of a plone ontology tool.