2

同じタイトルの投稿を見ましたが、残念ながら、与えられた例を見て解決策を見つけることができませんでした

次の方法でノードを作成しました。

private static void createExampleNetwork(GraphClient client)
    {
        try
        {
            //CypherQuery cq = new CypherQuery();
            //string createNodeQuery = "CREATE (a {name : 'Andres'}) RETURN";
            //string response = cq.CreateRequest(createNodeQuery);

            var myNodeReferenceA = client.Create(new ExampleNode { Name = "A" });
            var myNodeReferenceB = client.Create(new ExampleNode { Name = "B" });
            var myNodeReferenceC = client.Create(new ExampleNode { Name = "C" });
            var myNodeReferenceD = client.Create(new ExampleNode { Name = "D" });
            var myNodeReferenceE = client.Create(new ExampleNode { Name = "E" });
            var myNodeReferenceF = client.Create(new ExampleNode { Name = "F" });
            var myNodeReferenceG = client.Create(new ExampleNode { Name = "G" });
        }
        catch (Exception ex)
        {

        }
    }

次の関係を作成したいと思います: A--B A--C A--D C--D B--G

しかし、方法がわからない。

http://hg.readify.net/neo4jclient/src/4693da483a90/Test/RelationshipTests.cshttp://hg.readify.net/neo4jclient/src/4693da483a90/Test/ApiUsageIdeas.csの例を見てきました

しかし、関係がどのように作成されるかはまだわかりません。

誰かが有用な例を挙げることができれば、私は非常に感謝しています。

4

1 に答える 1

4

私は解決策を見つけました

private static void createExampleNetwork(GraphClient client)
    {
        try
        {

            var myNodeReferenceA = client.Create(new ExampleNode { Name = "A" });
            var myNodeReferenceB = client.Create(new ExampleNode { Name = "B" });
            var myNodeReferenceC = client.Create(new ExampleNode { Name = "C" });
            var myNodeReferenceD = client.Create(new ExampleNode { Name = "D" });
            var myNodeReferenceE = client.Create(new ExampleNode { Name = "E" });
            var myNodeReferenceF = client.Create(new ExampleNode { Name = "F" });
            var myNodeReferenceG = client.Create(new ExampleNode { Name = "G" });

            client.CreateRelationship(myNodeReferenceA, new NodeKnows(myNodeReferenceB));
            client.CreateRelationship(myNodeReferenceA, new NodeKnows(myNodeReferenceC));
            client.CreateRelationship(myNodeReferenceA, new NodeKnows(myNodeReferenceD));
            client.CreateRelationship(myNodeReferenceA, new NodeKnows(myNodeReferenceE));
            client.CreateRelationship(myNodeReferenceB, new NodeKnows(myNodeReferenceF));
            client.CreateRelationship(myNodeReferenceB, new NodeKnows(myNodeReferenceG));
            client.CreateRelationship(myNodeReferenceC, new NodeKnows(myNodeReferenceD));
            client.CreateRelationship(myNodeReferenceE, new NodeKnows(myNodeReferenceF));
        }
        catch (Exception ex)
        {

        }
    }

 public class NodeKnows :Relationship, IRelationshipAllowingSourceNode<ExampleNode>, IRelationshipAllowingTargetNode<ExampleNode>
{
    public NodeKnows(NodeReference targetNode)
        : base(targetNode)
    {
    }

    public const string TypeKey = "KNOWS";
    public override string RelationshipTypeKey
    {
        get { return TypeKey; }
    }
}
于 2012-06-09T13:44:23.567 に答える