Thanks. My frustration is that I want to automatically detect all subgraph, which means I dont't know how to determine a list of "one node of each sub-graph". But using collect in cypher is pretty good hint. I'm also concerned about the performance.
在 2017年4月12日星期三 UTC+8上午3:05:41,Michael Hunger写道: > > 1. you probably don't need bi-directional relationships, one is good > enough. > > 2. one way to get the subgraphs is to get one node of each sub-graph and > return all paths for that node up to a certain length. > > MATCH (n:Node) where n.name IN ["foo", "bar"] > MATCH path = (n)-[*..5]-() > UNWIND nodes(path) as node > RETURN n, collect(distinct node) as nodes > > 3. you can also use the path-expand > <https://neo4j-contrib.github.io/neo4j-apoc-procedures/#_graph_algorithms> > and clustering algorithms in the APOC procedure library > > On Tue, Apr 11, 2017 at 11:17 AM, Kai Wang <[email protected] > <javascript:>> wrote: > >> Hi,all, >> >> I'm using neo4j and I build a large graph that has a lot of subgraph. For >> example, in the pic below there are 4 subgraphs. How can I get 4 groups >> of nodes by cypher query? I mean it can return [node1, node2, node3], >> [node4, node5], [node6, node7, node8] ,each list represent a subgraph. >> >> >> <https://lh3.googleusercontent.com/-YcXm2szn3mw/WOyef6pE-vI/AAAAAAAAAA8/TVB1mWQzJY0sSuLfkwjb6JbEQoDq06Z3gCLcB/s1600/%25E5%2590%258C%25E4%25B9%2589%25E8%25AF%258D%25E7%25BD%2591%25E7%25BB%259C.PNG> >> >> >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Neo4j" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
