Boris,
Have you given Cypher as a pattern matching language a try,
http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html

It is kind of superseding the graph matching component.

/peter

Sent from my phone, please excuse typos and autocorrection.
On Dec 14, 2011 4:43 PM, "bm" <boris.m...@optilab.net> wrote:

>  Hi!
>
> I tried to use graph mather as a simple subgraph finder... unfortunately it
> doesn't work the way its supposed to.
>
> 1. I create simple graph:
>
>       * Node node1 = graphDb.createNode();
>        node1.setProperty(ID_KEY, 100001);
>        node1.setProperty(TYPE_KEY, 'E');
>
>        Node node2 = graphDb.createNode();
>        node2.setProperty(ID_KEY, 100002);
>        node2.setProperty(TYPE_KEY, 'V');
>
>
>        Node node3 = graphDb.createNode();
>        node3.setProperty(ID_KEY, 100003);
>        node3.setProperty(TYPE_KEY, 'V');
>
>
>        Node node4 = graphDb.createNode();
>        node4.setProperty(ID_KEY, 100004);
>        node4.setProperty(TYPE_KEY, 'E');
>
>        Node node5 = graphDb.createNode();
>        node5.setProperty(ID_KEY, 100005);
>        node5.setProperty(TYPE_KEY, 'E');
>
>        Node node6 = graphDb.createNode();
>        node6.setProperty(ID_KEY, 100006);
>        node6.setProperty(TYPE_KEY, 'E');
>
>
>        node1.createRelationshipTo(node2, RelTypes.INVOLVED);
>        node2.createRelationshipTo(node4, RelTypes.INVOLVED);
>        node4.createRelationshipTo(node3, RelTypes.INVOLVED);
>        node3.createRelationshipTo(node1, RelTypes.INVOLVED);
>        node2.createRelationshipTo(node6, RelTypes.INVOLVED);
>        node6.createRelationshipTo(node5, RelTypes.INVOLVED);
>        node5.createRelationshipTo(node4, RelTypes.INVOLVED);*
>
> here <http://shrani.si/f/5/f7/1DKus39y/picture1.jpg>is a picture how it
> looks like.
>
> 2. Then I create simple pattern graph:
>
>      *  PatternNode patternNode1 = new PatternNode();
>
>        patternNode1.addPropertyConstraint(TYPE_KEY, new
> ValueMatcherImpl('E'));
>
>        PatternNode patternNode2 = new PatternNode();
>        patternNode2.addPropertyConstraint(TYPE_KEY, new
> ValueMatcherImpl('V'));
>
>        PatternNode patternNode3 = new PatternNode();
>        patternNode3.addPropertyConstraint(TYPE_KEY, new
> ValueMatcherImpl('V'));
>
>        PatternNode patternNode4 = new PatternNode();
>        patternNode4.addPropertyConstraint(TYPE_KEY, new
> ValueMatcherImpl('E'));
>
>        PatternNode patternNode5 = new PatternNode();
>        patternNode5.addPropertyConstraint(TYPE_KEY, new
> ValueMatcherImpl('E'));
>
>        PatternNode patternNode6 = new PatternNode();
>        patternNode6.addPropertyConstraint(TYPE_KEY, new
> ValueMatcherImpl('E'));
>
>
>        patternNode1.createRelationshipTo(patternNode2, Direction.BOTH);
>        patternNode2.createRelationshipTo(patternNode4, Direction.BOTH);
>        patternNode1.createRelationshipTo(patternNode3, Direction.BOTH);
>        patternNode3.createRelationshipTo(patternNode4, Direction.BOTH);*
>
> link <http://shrani.si/f/Y/C6/3AUZFjuo/picture2.jpg>to picture.
>
> 3. Finally I try to find graph:
>
>       * PatternMatcher matcher = PatternMatcher.getMatcher();
>
>        Iterable<PatternMatch> matches = matcher.match(patternNode1, node1);
>
>         for (PatternMatch match : matches) {
>             System.out.println("\nFOUND MATCH: ");
>             for(PatternElement element: match.getElements())
>                 System.out.print(element.getNode().getProperty(TYPE_KEY)+
> " - "+element.getNode().getProperty(ID_KEY)+" ");
>         }*
>
>
> Starting node is always the leftmost node in pictures.
>
> RESULT:
>
> FOUND MATCH:
> E - 100004 E - 100001 V - 100003 V - 100002
> FOUND MATCH:
> E - 100004 E - 100001 V - 100002 V - 100003
> FOUND MATCH:
> E - 100004 E - 100006 V - 100002 V - 100003
>
> First 2 results are fine. Second is just automorphism of first. Third
> result is totaly wrong.
>
> Is there something I am doing wrong? Will graph-matching ever support*
> true*graph matching?
>
>
> Sorry for bad english.
>
> Have a nice day. :)
> _______________________________________________
> NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please
> register and consider posting at
> https://groups.google.com/forum/#!forum/neo4j
>
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register 
and consider posting at https://groups.google.com/forum/#!forum/neo4j

Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to