Skip to content

NXTranslator.get_instance() can not return a MultiGraph #375

Description

@svove

Memgraph version Which version did you use?
v3.7.1

Environment Some information about the environment you are using Memgraph
I am using Memgraph in a docker container and am connecting via NxTranslator.

Describe the bug A clear and concise description of what the bug is.
Not necessarily a bug but unexpected behavior.
I have added a MultiDiGraph with NXTranslator which is correctly added to my Memgraph instance using a simpler helper function with 61,102 edges. After retrieving the graph from Memgraph with NxTranslator().get_instance() the graph is automatically converted to a DiGraph and thereby reducing 61,102 edges to about 14,000 edges with my data.

To Reproduce Steps to reproduce the behavior:

  1. Create arbitrary nx.MultiDiGraph and add to Memgraph with NxTranslator.
  2. Retrieve graph from Memgraph with NxTranslator.get_instance().
  3. Compare edge counts before and after insert/retrieval.

My small wrapper functions for adding and removing a graph with NxTranslator:

def add_networkx_to_memgraph(graph:nx.Graph, drop_existing:bool=True, port:int=7687):
        memgraph = Memgraph(port=port)
        if drop_existing:
            memgraph.drop_database()
        translator = NxTranslator()

        for query in list(translator.to_cypher_queries(graph)):
            memgraph.execute(query)
def get_graph_from_memgraph(host:str='127.0.0.1', port:int=7687) -> nx.Graph:
        # memgraph = Memgraph(port=port)
        graph = NxTranslator(host=host, port=port).get_instance()
        return graph

Other
It seems in nx_translator.py line 281 the type of the nx-graph is hardcoded to nx.DiGraph.

Metadata

Metadata

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions