Package org.neo4j.graphalgo.api
Class FilterGraph
- java.lang.Object
-
- org.neo4j.graphalgo.api.FilterGraph
-
- All Implemented Interfaces:
BatchNodeIterable
,Degrees
,Graph
,IdMapping
,NodeIterator
,NodeMapping
,NodePropertyContainer
,RelationshipAccess
,RelationshipIterator
,RelationshipPredicate
,RelationshipProperties
- Direct Known Subclasses:
NodeFilteredGraph
public abstract class FilterGraph extends java.lang.Object implements Graph
-
-
Field Summary
Fields Modifier and Type Field Description protected Graph
graph
-
Fields inherited from interface org.neo4j.graphalgo.api.IdMapping
START_NODE_ID
-
-
Constructor Summary
Constructors Constructor Description FilterGraph(Graph graph)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<NodeLabel>
availableNodeLabels()
java.util.Set<java.lang.String>
availableNodeProperties()
java.util.Collection<PrimitiveLongIterable>
batchIterables(int batchSize)
void
canRelease(boolean canRelease)
boolean
contains(long nodeId)
Returns true iff the nodeId is mapped, otherwise false.boolean
containsOnlyAllNodesLabel()
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)
void
forEachNode(java.util.function.LongPredicate consumer)
Iterate over each nodeIdvoid
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.long
getTarget(long nodeId, long index)
boolean
hasLabel(long nodeId, NodeLabel label)
boolean
hasRelationshipProperty()
RelationshipIntersect
intersection()
RelationshipIntersect
intersection(long maxDegree)
boolean
isEmpty()
boolean
isMultiGraph()
Whether the graph is guaranteed to have no parallel relationships.boolean
isUndirected()
long
nodeCount()
Number of mapped nodeIds.PrimitiveLongIterator
nodeIterator()
java.util.Set<NodeLabel>
nodeLabels(long nodeId)
NodeMapping
nodeMapping()
NodeProperties
nodeProperties(java.lang.String propertyKey)
Return the property values for a property keylong
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 idvoid
release()
Release all resources which are not part of the result or IdMappingvoid
releaseProperties()
Release only the properties associated with that graph.void
releaseTopology()
Release only the topological data associated with that graph.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 nodeId-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.neo4j.graphalgo.api.Graph
concurrentCopy
-
-
-
-
Field Detail
-
graph
protected final Graph graph
-
-
Constructor Detail
-
FilterGraph
public FilterGraph(Graph graph)
-
-
Method Detail
-
relationshipCount
public long relationshipCount()
- Specified by:
relationshipCount
in interfaceGraph
- Returns:
- returns the total number of relationships in the graph.
-
isUndirected
public boolean isUndirected()
- Specified by:
isUndirected
in interfaceGraph
-
hasRelationshipProperty
public boolean hasRelationshipProperty()
- Specified by:
hasRelationshipProperty
in interfaceGraph
-
canRelease
public void canRelease(boolean canRelease)
- Specified by:
canRelease
in interfaceGraph
-
intersection
public RelationshipIntersect intersection(long maxDegree)
- Specified by:
intersection
in interfaceGraph
-
batchIterables
public java.util.Collection<PrimitiveLongIterable> batchIterables(int batchSize)
- Specified by:
batchIterables
in interfaceBatchNodeIterable
- Returns:
- a collection of iterables over every node, partitioned by the given batch size.
-
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()
-
nodeMapping
public NodeMapping nodeMapping()
- Specified by:
nodeMapping
in interfaceGraph
-
toMappedNodeId
public long toMappedNodeId(long nodeId)
Description copied from interface:IdMapping
Map original nodeId to inner nodeId- Specified by:
toMappedNodeId
in interfaceIdMapping
-
toOriginalNodeId
public long toOriginalNodeId(long nodeId)
Description copied from interface:IdMapping
Map inner nodeId back to original nodeId- Specified by:
toOriginalNodeId
in interfaceIdMapping
-
contains
public boolean contains(long nodeId)
Description copied from interface:IdMapping
Returns true iff the nodeId is mapped, otherwise false.
-
nodeCount
public long nodeCount()
Description copied from interface:IdMapping
Number of mapped nodeIds.
-
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 PrimitiveLongIterator nodeIterator()
- Specified by:
nodeIterator
in interfaceNodeIterator
-
nodeLabels
public java.util.Set<NodeLabel> nodeLabels(long nodeId)
- Specified by:
nodeLabels
in interfaceGraph
- Specified by:
nodeLabels
in interfaceNodeMapping
-
availableNodeLabels
public java.util.Set<NodeLabel> availableNodeLabels()
- Specified by:
availableNodeLabels
in interfaceGraph
- Specified by:
availableNodeLabels
in interfaceNodeMapping
-
hasLabel
public boolean hasLabel(long nodeId, NodeLabel label)
- Specified by:
hasLabel
in interfaceNodeMapping
-
containsOnlyAllNodesLabel
public boolean containsOnlyAllNodesLabel()
- Specified by:
containsOnlyAllNodesLabel
in interfaceNodeMapping
-
nodeProperties
public NodeProperties nodeProperties(java.lang.String propertyKey)
Description copied from interface:NodePropertyContainer
Return the property values for a property key- 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
-
getTarget
public long getTarget(long nodeId, long index)
- Specified by:
getTarget
in interfaceRelationshipAccess
-
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
-
exists
public boolean exists(long sourceNodeId, long targetNodeId)
- Specified by:
exists
in interfaceRelationshipPredicate
-
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
-
intersection
public RelationshipIntersect intersection()
- Specified by:
intersection
in interfaceGraph
-
release
public void release()
Description copied from interface:Graph
Release all resources which are not part of the result or IdMapping
-
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
-
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.
-
-