Creating a matrix in Java and Neo4j

24 views
Skip to first unread message

Allison Sparrow

unread,
Oct 31, 2012, 3:11:19 PM10/31/12
to Azam Keypour, ne...@googlegroups.com
Hey all,

I'm adding Azam here who has a question:

I want to create a matrix in java that hold all of the paths between
two node in graph(in a very large graph) like attachment picture.
how can I do this with neo4j?

Any help would be useful!

Allison Sparrow
Marketing Manager | Neo Technology
+19499036091 |
@ayeeson
As a friend of Neo, register for GraphConnect and get a 20% discount. Code: GCFON
mat.bmp

Wes Freeman

unread,
Oct 31, 2012, 8:12:18 PM10/31/12
to ne...@googlegroups.com, Azam Keypour
In Cypher you could do something like this:

start n=node(1,2,3,4,5,6), _1=node(1), _2=node(2), _3=node(3), _4=node(4), _5=node(5), _6=node(6) 
return n-->_1, n-->_2, n-->_3, n-->_4, n-->_5, n-->_6
--
 
 

Wes Freeman

unread,
Oct 31, 2012, 8:16:09 PM10/31/12
to ne...@googlegroups.com, Azam Keypour
Actually I guess it's more like this:

start n=node(1,2,3,4,5,6), _1=node(1), _2=node(2), _3=node(3), _4=node(4), _5=node(5), _6=node(6) 
return n-[*]->_1, n-[*]->_2, n-[*]->_3, n-[*]->_4, n-[*]->_5, n-[*]->_6

Wes

Michael Hunger

unread,
Oct 31, 2012, 8:34:15 PM10/31/12
to ne...@googlegroups.com, Azam Keypour
Is it all paths or all-shortest-paths?

Usually in Java you would iterate twice over all nodes and using GraphAlgoFactory's 

algo = GraphAlgoFactory.allSimplePaths(StandardExpander.DEFAULT,maxDepth)
// or
algo=  GraphAlgoFactory.allPaths(StandardExpander.DEFAULT,maxDepth)

(or use any of the other expanders to find your relationships)

for (Node start : GlobalGraphOperations.at(db)) 
  for (Node end : GlobalGraphOperations.at(db)) 
    matrix.put(Pair.of(start,end), IteratorUtil.asCollection(algo.findAllPaths(start,end))

Michael
--
 
 
<mat.bmp>

Reply all
Reply to author
Forward
0 new messages