RedisGraph / redisgraph-py

RedisGraph python client
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
189 stars 49 forks source link

Are you considering using networkx? #4

Open ironhouzi opened 6 years ago

ironhouzi commented 6 years ago

NetworkX is the most common graph library for Python, and I was expecting this client to be utilizing it.

What are your thoughts on utilizing it?

swilly22 commented 6 years ago

An interesting idea, Let me experiment a bit with NetworkX to see if it's a good match

DeadWisdom commented 6 years ago

NetworkX is mostly about it's wonderful library of algorithms which, using a Redis module, wouldn't do much. I could see matching its interface (which is already basically there), and allowing easy transfer from NetworkX to Redis Graph and back again.

swilly22 commented 6 years ago

@DeadWisdom thanks, As I've said above I'm not that familiar with NetworkX, I'll have to read the docs and play with it a bit before deciding rather or not to add support (not sure about details) for RedisGraph to it.

schwab commented 5 years ago

This is an interesting idea, especially if graphs (ie match query results) could be pushed through the networkx library to have it output visualizations. One of the impediments I've been running into while converting an existing sql system to use redis graph, is that the "not-so-command-line-literate" of my colleagues are very dependent on visual tools to help them understand our data. Without something akin to column-row grid based sql tools, they are very confused by graphs. I know this is an education issue, but a usable graph visualization tool ( perhaps as a plugin to rediscommander), would go a long way towards bridging that gap. A quick way to get something useable and open innovation up to others would be an option to have redisgraph output graphs formatted in one or more of networkx's supported formats (GML, GraphML, json, adjacency lists etc). Then a simple load call followed by a draw would produce visualizations.

vsraptor commented 5 years ago

any news on this ...

swilly22 commented 5 years ago

@vsraptor, not much to update, we're currently working on restructuring our resultset format, the new structure will enable others to easily construct a visual representation of the result-set.

schwab commented 5 years ago

Checkout RedisInsight which has a graph visualization when you return nodes and relationships in a query.

vsraptor commented 4 years ago

quick and dirty .. for starters .. if from redis-cli you can call script and pass the result set as csv-tuples ... it will be very easy to chain to this function.


def draw(triple_lst):
    graph = nx.DiGraph(directed=True    )
    plt.figure()
    options = {
        'node_color': '#aaaaff',
        'node_size': 700,
        'width': 2,
        'arrowstyle': '-|>',
        'arrowsize': 12,
        'with_labels':True,
        'font_weight':'bold',
    }

    for triple in triple_lst :
        n1 = graph.add_node(triple[0])
        n2 = graph.add_node(triple[1])
        graph.add_edge(triple[0],triple[1], weight=f'{triple[2]:.2f}')
    pos = nx.spring_layout(graph)   
    nx.draw_networkx(graph, **options, pos=pos)
    edge_labels = nx.get_edge_attributes(graph, 'weight')
    nx.draw_networkx_edge_labels(graph, pos=pos, label_pos=0.5, edge_labels=edge_labels)
    return graph

draw(obj.graph.query("match (n1)-[e]->(n2) return n1.val, n2.val, e.val").result_set)

Figure_1