penman
penman copied to clipboard
Simple membership test: X in graph
It would be useful to have a simple way to test if a graph has certain elements. This would be done my implementing the __contains__() method on the Graph class.
I can imagine several behaviors based on the type of thing being checked:
- string (
'xyz' in g) - return True if the string is an attribute (i.e. terminal) value - Graph (
Graph(...) in g) - return True if the query graph is isomorphic to a subgraph of g - tuple (
('x', 'polarity', '-') in g) - return True if the query tuple is a triple in g
To start, maybe we should just consider string values.