aplbrain / dotmotif

A performant, powerful query framework to search for network motifs
https://bossdb.org/tools/dotmotif
Apache License 2.0
81 stars 9 forks source link

Non-string ids not supported by Neo4jExecutor #26

Closed jtpdowns closed 5 years ago

jtpdowns commented 5 years ago

Ingesting a NetworkX graph with integer ids results in an error: ValueError: Could not export graph: unsupported operand type(s) for +: 'int' and 'str'. It should be straightforward to handle integers, though A node can be any hashable Python object except None. Maybe just cast with repr.

j6k4m8 commented 5 years ago

I think I want the user to explicitly perform the rename, since they'll have to know what these node IDs are later in order to index the results back into the starting graph.

For example, this is weird:

>>> E = Executor(graph=G)
>>> results = E.find(motif, cursor=False)
>>> results[0][0] in G
False

Granted, str(results[0][0]) in GTrue, but I'm not sure that'd be obvious if this happens silently. Thoughts?

j6k4m8 commented 5 years ago

This is resolved in #40.

To make your int-ID'd graph compatible with dotmotif, one can rename the IDs in a NetworkX graph:

Given a networkx.Graph called G:

import networkx as nx

G = nx.relabel_nodes(G, lambda x: str(x))