Hi, Amir.

That is because you are calling "getEndNode()" when printing the output,
which is a direction-specific method.  You should be calling
"getOtherNode()".

Regards,

Rick


-----Original Message-----
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On
Behalf Of Amir Hossein Jadidinejad
Sent: Thursday, March 04, 2010 5:08 PM
To: neo4j
Subject: [Neo] Undirected relationships

Hi,
I'm going to setup a Nearest Neighbour Graph. Its relations are not
directed. How to define undirected relationships in Neo4j?
By the way, I'm confused with relations! check the following codes to create
a simple graph:
        GraphDatabaseService graphDb = new EmbeddedGraphDatabase("var");

        IndexService index = new LuceneIndexService(graphDb);

        Transaction tx = graphDb.beginTx();
        try {
            Node andy = graphDb.createNode();
            Node larry = graphDb.createNode();

            andy.setProperty("name", "Andy Wachowski");
            index.index(andy, "name", andy.getProperty("name"));

            larry.setProperty("name", "Larry Wachowski");
            index.index(larry, "name", larry.getProperty("name"));

            andy.createRelationshipTo(larry, MyRelationshipTypes.KNOWS);

            tx.success();

        } finally {
            tx.finish();
            index.shutdown();
            graphDb.shutdown();
        }

This is a simple relations from "andy" to "larry". When I print the
neighbours of "larry" by the following codes:
            Node a = index.getSingleNode("name", "Larry Wachowski");
            System.out.println("Relations:");
            for(Relationship r: a.getRelationships())
                System.out.println(r.getEndNode().getProperty("name"));

The output is:
Relations:
Larry Wachowski

It means that "larry" is related to himself! why?
Kind regards,
Amir



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

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

Reply via email to