Exemplo n.º 1
0
        private int DegreeForDirectionAndType(StorageNodeCursor cursor, RelationshipDirection direction, int relType)
        {
            int degree = 0;

            using (StorageRelationshipGroupCursor groups = StorageReader.allocateRelationshipGroupCursor())
            {
                groups.Init(cursor.EntityReference(), cursor.RelationshipGroupReference());
                while (groups.Next())
                {
                    if (relType == ANY_RELATIONSHIP_TYPE || relType == groups.Type())
                    {
                        switch (direction)
                        {
                        case RelationshipDirection.OUTGOING:
                            degree += groups.OutgoingCount() + groups.LoopCount();
                            break;

                        case RelationshipDirection.INCOMING:
                            degree += groups.IncomingCount() + groups.LoopCount();
                            break;

                        case RelationshipDirection.LOOP:
                            degree += groups.OutgoingCount() + groups.IncomingCount() + groups.LoopCount();
                            break;

                        default:
                            throw new System.ArgumentException(direction.name());
                        }
                    }
                }
            }
            return(degree);
        }
Exemplo n.º 2
0
        private ISet <TestDegreeItem> Degrees(StorageNodeCursor nodeCursor)
        {
            ISet <TestDegreeItem> degrees = new HashSet <TestDegreeItem>();

            using (StorageRelationshipGroupCursor groups = StorageReader.allocateRelationshipGroupCursor())
            {
                groups.Init(nodeCursor.EntityReference(), nodeCursor.RelationshipGroupReference());
                while (groups.Next())
                {
                    degrees.Add(new TestDegreeItem(groups.Type(), groups.OutgoingCount() + groups.LoopCount(), groups.IncomingCount() + groups.LoopCount()));
                }
            }
            return(degrees);
        }
Exemplo n.º 3
0
        private ISet <TestRelType> RelTypes(StorageNodeCursor cursor)
        {
            ISet <TestRelType> types = new HashSet <TestRelType>();

            using (StorageRelationshipGroupCursor groups = StorageReader.allocateRelationshipGroupCursor())
            {
                groups.Init(cursor.EntityReference(), cursor.RelationshipGroupReference());
                while (groups.Next())
                {
                    types.Add(RelTypeForId(groups.Type()));
                }
            }
            return(types);
        }