Class UnionGraph

    • Method Detail

      • nodeCount

        public long nodeCount()
        Description copied from interface: IdMap
        Number of mapped nodeIds.
        Specified by:
        nodeCount in interface IdMap
      • 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
      • 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
      • 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
      • schema

        public org.neo4j.gds.api.schema.GraphSchema schema()
        Specified by:
        schema in interface Graph
      • relationshipCount

        public long relationshipCount()
        Specified by:
        relationshipCount in interface Graph
        Returns:
        returns the total number of relationships in the graph.
      • batchIterables

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

        public void forEachNode​(java.util.function.LongPredicate consumer)
        Description copied from interface: NodeIterator
        Iterate over each nodeId
        Specified by:
        forEachNode in interface NodeIterator
      • nodeIterator

        public java.util.PrimitiveIterator.OfLong nodeIterator()
        Specified by:
        nodeIterator in interface NodeIterator
      • nodeIterator

        public java.util.PrimitiveIterator.OfLong nodeIterator​(java.util.Set<org.neo4j.gds.NodeLabel> labels)
        Specified by:
        nodeIterator in interface NodeIterator
      • 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
        Parameters:
        propertyKey - the node property key
        Returns:
        the values associated with that key
      • 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
        Parameters:
        originalNodeId - must be smaller or equal to the id returned by IdMap.highestOriginalId()
      • 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
      • 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
      • rootIdMap

        public IdMap rootIdMap()
        Description copied from interface: IdMap
        Returns the original node mapping if the current node mapping is filtered, otherwise it returns itself.
        Specified by:
        rootIdMap in interface IdMap
      • containsOriginalId

        public boolean containsOriginalId​(long originalNodeId)
        Description copied from interface: IdMap
        Returns true iff the Neo4j id is mapped, otherwise false.
        Specified by:
        containsOriginalId in interface IdMap
      • 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
        Parameters:
        sourceNodeId - source node
        targetNodeId - target node
        fallbackValue - value to use if relationship has no property value
        Returns:
        the property value
      • relationshipProperty

        public double relationshipProperty​(long sourceNodeId,
                                           long targetNodeId)
        Description copied from interface: RelationshipProperties
        Returns the property value for a relationship defined by its source and target nodes.
        Specified by:
        relationshipProperty in interface RelationshipProperties
      • forEachRelationship

        public void forEachRelationship​(long nodeId,
                                        RelationshipConsumer consumer)
        Description copied from interface: RelationshipIterator
        Calls the given consumer function for every relationship of a given node.
        Specified by:
        forEachRelationship in interface RelationshipIterator
        Parameters:
        nodeId - id of the node for which to iterate relationships
        consumer - relationship consumer function
      • 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
        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
      • forEachInverseRelationship

        public void forEachInverseRelationship​(long nodeId,
                                               RelationshipConsumer consumer)
        Description copied from interface: RelationshipIterator
        Calls the given consumer for every inverse relationship of a given node. Inverse relationships basically mirror the relationships in that graph. For example, if `Graph.forEachRelationship(42)` returns `1337` then the result of `forEachInverseRelationship(1337)` contains `42. For undirected graphs, accessing the inverse relationships is never supported.

        Note, that this the inverse index might not always be present. Check Graph.characteristics() before calling this method to verify that the graphs is inverse indexed.

        Specified by:
        forEachInverseRelationship in interface RelationshipIterator
        Parameters:
        nodeId - id of the node for which to iterate the inverse relationships
        consumer - relationship consumer function
      • forEachInverseRelationship

        public void forEachInverseRelationship​(long nodeId,
                                               double fallbackValue,
                                               RelationshipWithPropertyConsumer consumer)
        Description copied from interface: RelationshipIterator
        Calls the given consumer for every inverse 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.

        Inverse relationships basically mirror the relationships in that graph. For example, if `Graph.forEachRelationship(42)` returns `1337` then the result of `forEachInverseRelationship(1337)` contains `42. For undirected graphs, accessing the inverse relationships is never supported.

        Note, that this the inverse index might not always be present. Check Graph.characteristics() before calling this method to verify that the graphs is inverse indexed.

        Specified by:
        forEachInverseRelationship in interface RelationshipIterator
        Parameters:
        nodeId - id of the node for which to iterate the inverse 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
        Parameters:
        nodeId - id of the node for which to stream the relationships
        fallbackValue - value used as relationship property if no properties were loaded
      • relationshipTypeFilteredGraph

        public Graph relationshipTypeFilteredGraph​(java.util.Set<org.neo4j.gds.RelationshipType> relationshipTypes)
        Specified by:
        relationshipTypeFilteredGraph in interface Graph
      • 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
      • degreeInverse

        public int degreeInverse​(long nodeId)
        Description copied from interface: Degrees
        Returns the number of relationships connected to that node. For directed graphs, this is the number of incoming edges. For undirected graphs, the behaviour of this method is undefined. Note, that this is an optional feature, and it is up to the implementation if this is actually supported. Check Graph.characteristics() before calling this method to verify that the graphs is inverse indexed.
        Specified by:
        degreeInverse in interface Degrees
      • 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
      • exists

        public boolean exists​(long sourceNodeId,
                              long targetNodeId)
        O(n) !
        Specified by:
        exists in interface RelationshipPredicate
      • 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
        offset - the n-th target to return. Must be positive.
        Returns:
        the target at the offset or -1 if there is no such target.
      • isMultiGraph

        public boolean isMultiGraph()
        Description copied from interface: Graph
        Whether the graph is guaranteed to have no parallel relationships. If this returns false it still may be parallel-free, but we do not know.
        Specified by:
        isMultiGraph in interface Graph
        Returns:
        true iff the graph has maximum one relationship between each pair of nodes.
      • nodeLabels

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

        public java.util.Set<org.neo4j.gds.NodeLabel> availableNodeLabels()
        Specified by:
        availableNodeLabels in interface IdMap
      • hasLabel

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

        public boolean isNodeFilteredGraph()
      • addNodeLabel

        public void addNodeLabel​(org.neo4j.gds.NodeLabel nodeLabel)
        Description copied from interface: IdMap
        Adds new node label to the available node labels. The labels is not assigned to any nodes at this point.
        Specified by:
        addNodeLabel in interface IdMap
        Parameters:
        nodeLabel - the node label to add
      • addNodeIdToLabel

        public void addNodeIdToLabel​(long mappedNodeId,
                                     org.neo4j.gds.NodeLabel nodeLabel)
        Description copied from interface: IdMap
        Assigns a node to the given node label.
        Specified by:
        addNodeIdToLabel in interface IdMap
        Parameters:
        mappedNodeId - the node id to assign
        nodeLabel - the node label to which the node will be assigned to