Class NodeFilteredGraph

    • Constructor Detail

    • Method Detail

      • schema

        public org.neo4j.gds.api.schema.GraphSchema schema()
        Specified by:
        schema in interface Graph
        Overrides:
        schema in class GraphAdapter
      • batchIterables

        public java.util.Collection<org.neo4j.gds.collections.primitive.PrimitiveLongIterable> batchIterables​(long batchSize)
        Specified by:
        batchIterables in interface BatchNodeIterable
        Overrides:
        batchIterables in class GraphAdapter
        Returns:
        a collection of iterables over every node, partitioned by the given batch size.
      • degree

        public int degree​(long nodeId)
        Description copied from interface: Degrees
        Returns the number of relationships connected to that node. For undirected graphs, this includes outgoing and incoming relationships. For directed graphs, this is the number of outgoing edges.
        Specified by:
        degree in interface Degrees
        Overrides:
        degree in class GraphAdapter
      • nodeCount

        public long nodeCount​(org.neo4j.gds.NodeLabel nodeLabel)
        Description copied from interface: IdMap
        Number of mapped nodeIds for a specific node label.
        Specified by:
        nodeCount in interface IdMap
        Overrides:
        nodeCount in class GraphAdapter
      • rootNodeCount

        public java.util.OptionalLong rootNodeCount()
        Description copied from interface: PartialIdMap
        Number of mapped node ids in the root mapping. This is necessary for nested (filtered) id mappings.
        Specified by:
        rootNodeCount in interface PartialIdMap
        Overrides:
        rootNodeCount in class GraphAdapter
      • highestOriginalId

        public long highestOriginalId()
        Description copied from interface: IdMap
        The highest id that is mapped in this id mapping.

        The value is the upper bound of the original node id space.

        Specified by:
        highestOriginalId in interface IdMap
        Overrides:
        highestOriginalId in class GraphAdapter
      • toMappedNodeId

        public long toMappedNodeId​(long originalNodeId)
        Description copied from interface: PartialIdMap
        Maps an original node id to a mapped node id. In case of nested id maps, the mapped node id is always in the space of the innermost mapping.
        Specified by:
        toMappedNodeId in interface PartialIdMap
        Overrides:
        toMappedNodeId in class GraphAdapter
        Parameters:
        originalNodeId - must be smaller or equal to the id returned by IdMap.highestOriginalId()
      • toRootNodeId

        public long toRootNodeId​(long mappedNodeId)
        Description copied from interface: IdMap
        Maps a filtered mapped node id to its root mapped node id. This is necessary for nested (filtered) id mappings. If this mapping is a nested mapping, this method returns the root mapped node id of the parent mapping. For the root mapping this method returns the given node id.
        Specified by:
        toRootNodeId in interface IdMap
        Overrides:
        toRootNodeId in class GraphAdapter
      • toOriginalNodeId

        public long toOriginalNodeId​(long mappedNodeId)
        Description copied from interface: IdMap
        Returns the original node id for the given mapped node id. The original node id is typically the Neo4j node id. This method is guaranteed to always return the Neo4j id, regardless of the given mapped node id refers to a filtered node id space or a regular / unfiltered node id space.
        Specified by:
        toOriginalNodeId in interface IdMap
        Overrides:
        toOriginalNodeId in class GraphAdapter
      • toFilteredNodeId

        public long toFilteredNodeId​(long rootNodeId)
        Description copied from interface: FilteredIdMap
        Maps a root mapped node id to a filtered mapped node id. This is necessary for nested (filtered) id mappings. If this mapping is a nested mapping, this method returns the mapped id corresponding to the mapped id of the parent mapping. For the root mapping this method returns the given node id.
        Specified by:
        toFilteredNodeId in interface FilteredIdMap
      • containsRootNodeId

        public boolean containsRootNodeId​(long rootNodeId)
        Description copied from interface: FilteredIdMap
        Checks if the rootNodeId (mappedNodeId) is present in the IdMaps mapping information.
        Specified by:
        containsRootNodeId in interface FilteredIdMap
      • forEachRelationship

        public void forEachRelationship​(long nodeId,
                                        double fallbackValue,
                                        RelationshipWithPropertyConsumer consumer)
        Description copied from interface: RelationshipIterator
        Calls the given consumer function for every relationship of a given node. If the graph was loaded with a relationship property, the property value of the relationship will be passed into the consumer, otherwise the given fallback value will be used.
        Specified by:
        forEachRelationship in interface RelationshipIterator
        Overrides:
        forEachRelationship in class GraphAdapter
        Parameters:
        nodeId - id of the node for which to iterate relationships
        fallbackValue - value used as relationship property if no properties were loaded
        consumer - relationship consumer function
      • streamRelationships

        public java.util.stream.Stream<RelationshipCursor> streamRelationships​(long nodeId,
                                                                               double fallbackValue)
        Description copied from interface: RelationshipIterator
        Returns a stream which returns every relationship in the graph starting from the given node id. The id space returned for source and target nodes is the internal id space with respect to the graph this method was called on.

        The object returned by the stream is a single instance of RelationshipCursor. The same instance is used for every element in the stream and should thus not be stored for later use but instead be consumed directly before consuming the next element of the stream.

        Specified by:
        streamRelationships in interface RelationshipIterator
        Overrides:
        streamRelationships in class GraphAdapter
        Parameters:
        nodeId - id of the node for which to stream the relationships
        fallbackValue - value used as relationship property if no properties were loaded
      • asNodeFilteredGraph

        public java.util.Optional<NodeFilteredGraph> asNodeFilteredGraph()
        Description copied from interface: Graph
        If this graph is created using a node label filter, this will return a NodeFilteredGraph that represents the node set used in this graph. Be aware that it is not guaranteed to contain all relationships of the graph. Otherwise, it will return an empty Optional.
        Specified by:
        asNodeFilteredGraph in interface Graph
        Overrides:
        asNodeFilteredGraph in class GraphAdapter
      • nthTarget

        public long nthTarget​(long nodeId,
                              int offset)
        Description copied from interface: Graph
        Get the n-th target node id for a given sourceNodeId. The order of the targets is not defined and depends on the implementation of the graph, but it is consistent across separate calls to this method on the same graph. The sourceNodeId must be a node id existing in the graph. The offset parameter is 0-indexed and must be positive. If offset is greater than the number of targets for sourceNodeId, -1 is returned. It is undefined behavior if the sourceNodeId does not exist in the graph or the offset is negative.
        Specified by:
        nthTarget in interface Graph
        Overrides:
        nthTarget in class GraphAdapter
        offset - the n-th target to return. Must be positive.
        Returns:
        the target at the offset or -1 if there is no such target.
      • relationshipProperty

        public double relationshipProperty​(long sourceNodeId,
                                           long targetNodeId,
                                           double fallbackValue)
        Description copied from interface: RelationshipProperties
        get value of property on relationship between source and target node id
        Specified by:
        relationshipProperty in interface RelationshipProperties
        Overrides:
        relationshipProperty in class GraphAdapter
        Parameters:
        sourceNodeId - source node
        targetNodeId - target node
        fallbackValue - value to use if relationship has no property value
        Returns:
        the property value
      • nodeLabels

        public java.util.List<org.neo4j.gds.NodeLabel> nodeLabels​(long mappedNodeId)
        Specified by:
        nodeLabels in interface IdMap
        Overrides:
        nodeLabels in class GraphAdapter
      • hasLabel

        public boolean hasLabel​(long mappedNodeId,
                                org.neo4j.gds.NodeLabel label)
        Specified by:
        hasLabel in interface IdMap
        Overrides:
        hasLabel in class GraphAdapter
      • nodeProperties

        public NodePropertyValues nodeProperties​(java.lang.String propertyKey)
        Description copied from interface: NodePropertyContainer
        Return the property values for a property key NOTE: Avoid using this on the hot path, favor caching the NodeProperties object when possible
        Specified by:
        nodeProperties in interface NodePropertyContainer
        Overrides:
        nodeProperties in class GraphAdapter
        Parameters:
        propertyKey - the node property key
        Returns:
        the values associated with that key