redisgraph-py icon indicating copy to clipboard operation
redisgraph-py copied to clipboard

Are you considering using networkx?

Open ironhouzi opened this issue 6 years ago • 8 comments

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?

ironhouzi avatar Feb 04 '18 11:02 ironhouzi

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

swilly22 avatar Mar 17 '18 20:03 swilly22

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.

DeadWisdom avatar Mar 18 '18 00:03 DeadWisdom

@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.

swilly22 avatar Mar 18 '18 09:03 swilly22

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.

schwab avatar Nov 23 '18 15:11 schwab

any news on this ...

vsraptor avatar Apr 09 '19 05:04 vsraptor

@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.

swilly22 avatar Apr 09 '19 10:04 swilly22

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

schwab avatar Oct 31 '19 11:10 schwab

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

vsraptor avatar Aug 15 '20 23:08 vsraptor