Re: [Neo4j] Graph Matching Problem

11 views
Skip to first unread message

Mattias Persson

unread,
May 1, 2012, 6:19:18 PM5/1/12
to ne...@googlegroups.com
This might have been fixed in 1.7, there was a bug which made graph-matching return invalid results in some scenarios. You could try it out if you haven't moved over to using Cypher.

2012/2/27 Ethar <ethar....@gmail.com>
Hi, I am trying to use the graphmatching library to find patterns in the graph. My patterns are simple and are simply some structures(with no attribute/edge type constraints) like triangles, squares, square with one diagonal etc. The library seems to work fine with some patterns like triangles and squares. However, trying a square that has a diangonal is giving me wrong matches (some of the edges it claims to exist do not actually exist in the graph). I am posting my code snippet below and I will be grateful if you let me know if there is something I am doing wrong or is it some bug with the library.

P.S. I prefer to use the graphmatching library and not Cypher, as my code is already setup based on the graphmatching package. (below nodes is the set of nodes of the graph I am searching) Iterator<Node> it = nodes.iterator(); while(it.hasNext()){ Node startNode = it.next(); PatternNode p1 = new PatternNode(); PatternNode p2 = new PatternNode(); PatternNode p3 = new PatternNode(); PatternNode p4 = new PatternNode(); p1.setAssociation(startNode); p1.createRelationshipTo(p2); p1.createRelationshipTo(p3); p4.createRelationshipTo(p2); p4.createRelationshipTo(p3); p1.createRelationshipTo(p4);          PatternMatcher matcher = PatternMatcher.getMatcher();     Iterable<PatternMatch> matches = matcher.match( p1, startNode );     // Return the result     for ( PatternMatch match : matches)     {     Node n1 = match.getNodeFor(p1);     Node n2 = match.getNodeFor(p2);     Node n3 = match.getNodeFor(p3);     Node n4 = match.getNodeFor(p4);         } }



--
Mattias Persson, [mat...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com
Reply all
Reply to author
Forward
0 new messages