示例#1
0
def test_simple_index_nx_to_memgraph(memgraph: Memgraph):
    graph = nx.Graph()
    graph.add_nodes_from([
        (1, {
            "labels": "L1",
            "num": 123
        }),
        (2, {
            "labels": "L1",
            "num": 123
        }),
        (3, {
            "labels": ["L1", "L2", "L3"],
            "num": 123
        }),
    ])
    graph.add_edges_from([(1, 2), (1, 3)])
    expected_indexes = {
        MemgraphIndex("L1", "id"),
        MemgraphIndex("L2", "id"),
        MemgraphIndex("L3", "id"),
    }

    for query in nx_to_cypher(graph, NetworkXCypherConfig(create_index=True)):
        memgraph.execute(query)
    actual_indexes = set(memgraph.get_indexes())

    assert actual_indexes == expected_indexes
示例#2
0
def _check_for_index_hint(
    host: str = "127.0.0.1",
    port: int = 7687,
    username: str = "",
    password: str = "",
    encrypted: bool = False,
):
    """Check if the there are indexes, if not show warnings."""
    memgraph = Memgraph(host, port, username, password, encrypted)
    indexes = memgraph.get_indexes()
    if len(indexes) == 0:
        logging.getLogger(__file__).warning(
            "Be careful you do not have any indexes set up, the queries will take longer than expected!"
        )