def test_no_constraints_filter_found_one_vertex(self): graph = Graph() graph.add_vertex("dog", name="rex") spot = graph.add_vertex("dog", name="spot") spot2 = graph.get_or_create_vertex("dog", name="spot") self.assertEqual( spot2, spot, )
def test_no_constraints_filter_found_one_vertex(self): graph = Graph() graph.add_vertex("dog", name="rex") spot = graph.add_vertex("dog", name="spot") spot2 = graph.get_or_create_vertex("dog", name="spot") self.assertEqual( spot2, spot, )
from ruruki.graphs import Graph # create a empty graph graph = Graph() # create some constraints to ensure uniqueness graph.add_vertex_constraint("person", "name") graph.add_vertex_constraint("book", "title") graph.add_vertex_constraint("author", "fullname") graph.add_vertex_constraint("category", "name") # add in a couple books and their authors # Note that I am duplicating the books title property as a name too. This is for ruruki-eye display programming = graph.get_or_create_vertex("category", name="Programming") operating_systems = graph.get_or_create_vertex("category", name="Operating Systems") python_crash_course = graph.get_or_create_vertex("book", title="Python Crash Course") graph.set_property(python_crash_course, name="Python Crash Course") eric_matthes = graph.get_or_create_vertex("author", fullname="Eric Matthes", name="Eric", surname="Matthes") graph.get_or_create_edge(python_crash_course, "CATEGORY", programming) graph.get_or_create_edge(python_crash_course, "BY", eric_matthes) python_pocket_ref = graph.get_or_create_vertex("book", title="Python Pocket Reference") graph.set_property(python_pocket_ref, name="Python Pocket Reference") mark_lutz = graph.get_or_create_vertex("author", fullname="Mark Lutz", name="Mark", surname="Lutz") graph.get_or_create_edge(python_pocket_ref, "CATEGORY", programming) graph.get_or_create_edge(python_pocket_ref, "BY", mark_lutz)
#pylint: skip-file from ruruki.graphs import Graph # create a empty graph graph = Graph() # create some constraints to ensure uniqueness graph.add_vertex_constraint("person", "name") graph.add_vertex_constraint("book", "title") graph.add_vertex_constraint("author", "fullname") graph.add_vertex_constraint("category", "name") # add in a couple books and their authors # Note that I am duplicating the books title property as a name too. This is for ruruki-eye display programming = graph.get_or_create_vertex("category", name="Programming") operating_systems = graph.get_or_create_vertex("category", name="Operating Systems") python_crash_course = graph.get_or_create_vertex("book", title="Python Crash Course") graph.set_property(python_crash_course, name="Python Crash Course") eric_matthes = graph.get_or_create_vertex("author", fullname="Eric Matthes", name="Eric", surname="Matthes") graph.get_or_create_edge(python_crash_course, "CATEGORY", programming) graph.get_or_create_edge(python_crash_course, "BY", eric_matthes) python_pocket_ref = graph.get_or_create_vertex("book", title="Python Pocket Reference") graph.set_property(python_pocket_ref, name="Python Pocket Reference")