Package org.neo4j.gds.core.huge
Class UnionGraph
- java.lang.Object
-
- org.neo4j.gds.core.huge.UnionGraph
-
- All Implemented Interfaces:
BatchNodeIterable
,CSRGraph
,Degrees
,Graph
,IdMap
,NodeIterator
,PartialIdMap
,NodePropertyContainer
,RelationshipIterator
,RelationshipPredicate
,RelationshipProperties
public final class UnionGraph extends java.lang.Object implements CSRGraph
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.neo4j.gds.api.BatchNodeIterable
BatchNodeIterable.BitSetIdIterator, BatchNodeIterable.IdIterable, BatchNodeIterable.IdIterator
-
Nested classes/interfaces inherited from interface org.neo4j.gds.api.IdMap
IdMap.NodeLabelConsumer
-
-
Field Summary
-
Fields inherited from interface org.neo4j.gds.api.IdMap
NOT_FOUND, START_NODE_ID
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<NodeFilteredGraph>
asNodeFilteredGraph()
If this graph is created using a node label filter, this will return a NodeFilteredGraph that represents the node set used in this graph.java.util.Set<org.neo4j.gds.NodeLabel>
availableNodeLabels()
java.util.Set<java.lang.String>
availableNodeProperties()
java.util.Collection<PrimitiveLongIterable>
batchIterables(long batchSize)
void
canRelease(boolean canRelease)
CSRGraph
concurrentCopy()
boolean
contains(long nodeId)
Returns true iff the nodeId is mapped, otherwise false.int
degree(long nodeId)
int
degreeWithoutParallelRelationships(long nodeId)
Much slower than just degree() because it may have to look up all relationships.boolean
exists(long sourceNodeId, long targetNodeId)
O(n) !void
forEachNode(java.util.function.LongPredicate consumer)
Iterate over each nodeIdvoid
forEachNodeLabel(long nodeId, IdMap.NodeLabelConsumer consumer)
void
forEachRelationship(long nodeId, double fallbackValue, RelationshipWithPropertyConsumer consumer)
Calls the given consumer function for every relationship of a given node.void
forEachRelationship(long nodeId, RelationshipConsumer consumer)
Calls the given consumer function for every relationship of a given node.boolean
hasLabel(long nodeId, org.neo4j.gds.NodeLabel label)
boolean
hasRelationshipProperty()
long
highestNeoId()
boolean
isMultiGraph()
Whether the graph is guaranteed to have no parallel relationships.boolean
isNodeFilteredGraph()
long
nodeCount()
Number of mapped nodeIds.java.util.PrimitiveIterator.OfLong
nodeIterator()
java.util.PrimitiveIterator.OfLong
nodeIterator(java.util.Set<org.neo4j.gds.NodeLabel> labels)
java.util.List<org.neo4j.gds.NodeLabel>
nodeLabels(long nodeId)
NodePropertyValues
nodeProperties(java.lang.String propertyKey)
Return the property values for a property key NOTE: Avoid using this on the hot path, favor caching the NodeProperties object when possiblestatic CSRGraph
of(java.util.List<? extends CSRGraph> graphs)
long
relationshipCount()
double
relationshipProperty(long sourceNodeId, long targetNodeId)
Returns the property value for a relationship defined by its source and target nodes.double
relationshipProperty(long sourceNodeId, long targetNodeId, double fallbackValue)
get value of property on relationship between source and target node idjava.util.Map<org.neo4j.gds.RelationshipType,Relationships.Topology>
relationshipTopologies()
CompositeAdjacencyList
relationshipTopology()
Graph
relationshipTypeFilteredGraph(java.util.Set<org.neo4j.gds.RelationshipType> relationshipTypes)
void
releaseProperties()
Release only the properties associated with that graph.void
releaseTopology()
Release only the topological data associated with that graph.IdMap
rootIdMap()
Returns the original node mapping if the current node mapping is filtered, otherwise it returns itself.java.util.OptionalLong
rootNodeCount()
Number of mapped node ids in the root mapping.org.neo4j.gds.api.schema.GraphSchema
schema()
java.util.stream.Stream<RelationshipCursor>
streamRelationships(long nodeId, double fallbackValue)
long
toMappedNodeId(long nodeId)
Map original nodeId to inner nodeIdlong
toOriginalNodeId(long nodeId)
Map inner nodeId back to original nodeIdlong
toRootNodeId(long nodeId)
Maps an internal id to its root internal node id.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.neo4j.gds.api.IdMap
safeToMappedNodeId, withFilteredLabels
-
-
-
-
Method Detail
-
nodeCount
public long nodeCount()
Description copied from interface:IdMap
Number of mapped nodeIds.
-
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 interfacePartialIdMap
-
highestNeoId
public long highestNeoId()
- Specified by:
highestNeoId
in interfaceIdMap
-
relationshipCount
public long relationshipCount()
- Specified by:
relationshipCount
in interfaceGraph
- Returns:
- returns the total number of relationships in the graph.
-
batchIterables
public java.util.Collection<PrimitiveLongIterable> batchIterables(long batchSize)
- Specified by:
batchIterables
in interfaceBatchNodeIterable
- 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 interfaceNodeIterator
-
nodeIterator
public java.util.PrimitiveIterator.OfLong nodeIterator()
- Specified by:
nodeIterator
in interfaceNodeIterator
-
nodeIterator
public java.util.PrimitiveIterator.OfLong nodeIterator(java.util.Set<org.neo4j.gds.NodeLabel> labels)
- Specified by:
nodeIterator
in interfaceNodeIterator
-
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 interfaceNodePropertyContainer
- Parameters:
propertyKey
- the node property key- Returns:
- the values associated with that key
-
availableNodeProperties
public java.util.Set<java.lang.String> availableNodeProperties()
- Specified by:
availableNodeProperties
in interfaceNodePropertyContainer
-
toMappedNodeId
public long toMappedNodeId(long nodeId)
Description copied from interface:PartialIdMap
Map original nodeId to inner nodeId- Specified by:
toMappedNodeId
in interfacePartialIdMap
- Parameters:
nodeId
- must be smaller or equal to the id returned byIdMap.highestNeoId()
-
toOriginalNodeId
public long toOriginalNodeId(long nodeId)
Description copied from interface:IdMap
Map inner nodeId back to original nodeId- Specified by:
toOriginalNodeId
in interfaceIdMap
-
toRootNodeId
public long toRootNodeId(long nodeId)
Description copied from interface:IdMap
Maps an internal id to its root internal node id. This is necessary for nested (filtered) id mappings. If this mapping is a nested mapping, this method returns the root node id of the parent mapping. For the root mapping this method returns the given node id.- Specified by:
toRootNodeId
in interfaceIdMap
-
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.
-
contains
public boolean contains(long nodeId)
Description copied from interface:IdMap
Returns true iff the nodeId is mapped, otherwise false.
-
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 interfaceRelationshipProperties
- Parameters:
sourceNodeId
- source nodetargetNodeId
- target nodefallbackValue
- 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 interfaceRelationshipProperties
-
relationshipTopologies
public java.util.Map<org.neo4j.gds.RelationshipType,Relationships.Topology> relationshipTopologies()
- Specified by:
relationshipTopologies
in interfaceCSRGraph
-
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 interfaceRelationshipIterator
- Parameters:
nodeId
- id of the node for which to iterate relationshipsconsumer
- 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 interfaceRelationshipIterator
- Parameters:
nodeId
- id of the node for which to iterate relationshipsfallbackValue
- value used as relationship property if no properties were loadedconsumer
- relationship consumer function
-
streamRelationships
public java.util.stream.Stream<RelationshipCursor> streamRelationships(long nodeId, double fallbackValue)
- Specified by:
streamRelationships
in interfaceRelationshipIterator
-
relationshipTypeFilteredGraph
public Graph relationshipTypeFilteredGraph(java.util.Set<org.neo4j.gds.RelationshipType> relationshipTypes)
- Specified by:
relationshipTypeFilteredGraph
in interfaceGraph
-
degreeWithoutParallelRelationships
public int degreeWithoutParallelRelationships(long nodeId)
Description copied from interface:Degrees
Much slower than just degree() because it may have to look up all relationships.
This is not thread-safe, so if this is called concurrently please useRelationshipIterator.concurrentCopy()
.- Specified by:
degreeWithoutParallelRelationships
in interfaceDegrees
- See Also:
Graph.isMultiGraph()
-
concurrentCopy
public CSRGraph concurrentCopy()
- Specified by:
concurrentCopy
in interfaceCSRGraph
- Specified by:
concurrentCopy
in interfaceGraph
- Specified by:
concurrentCopy
in interfaceRelationshipIterator
- Returns:
- a copy of this iterator that reuses new cursors internally, so that iterations happen independent from other iterations.
-
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 interfaceGraph
-
exists
public boolean exists(long sourceNodeId, long targetNodeId)
O(n) !- Specified by:
exists
in interfaceRelationshipPredicate
-
canRelease
public void canRelease(boolean canRelease)
- Specified by:
canRelease
in interfaceGraph
-
releaseTopology
public void releaseTopology()
Description copied from interface:Graph
Release only the topological data associated with that graph.- Specified by:
releaseTopology
in interfaceGraph
-
releaseProperties
public void releaseProperties()
Description copied from interface:Graph
Release only the properties associated with that graph.- Specified by:
releaseProperties
in interfaceGraph
-
hasRelationshipProperty
public boolean hasRelationshipProperty()
- Specified by:
hasRelationshipProperty
in interfaceGraph
-
isMultiGraph
public boolean isMultiGraph()
Description copied from interface:Graph
Whether the graph is guaranteed to have no parallel relationships. If this returnsfalse
it still may be parallel-free, but we do not know.- Specified by:
isMultiGraph
in interfaceGraph
- Returns:
true
iff the graph has maximum one relationship between each pair of nodes.
-
relationshipTopology
public CompositeAdjacencyList relationshipTopology()
-
nodeLabels
public java.util.List<org.neo4j.gds.NodeLabel> nodeLabels(long nodeId)
- Specified by:
nodeLabels
in interfaceIdMap
-
forEachNodeLabel
public void forEachNodeLabel(long nodeId, IdMap.NodeLabelConsumer consumer)
- Specified by:
forEachNodeLabel
in interfaceIdMap
-
availableNodeLabels
public java.util.Set<org.neo4j.gds.NodeLabel> availableNodeLabels()
- Specified by:
availableNodeLabels
in interfaceIdMap
-
hasLabel
public boolean hasLabel(long nodeId, org.neo4j.gds.NodeLabel label)
-
isNodeFilteredGraph
public boolean isNodeFilteredGraph()
-
-