# APOC traversal and metadata

[Wiki](../README.md) / [APOC compatibility](README.md)

## APOC utilities, traversal and metadata

`apoc.coll.sortMaps(list, property)` and
`apoc.coll.sortMulti(list[, fields, limit, skip])` sort descending by default;
prefix a field with `^` for ascending. Sorting is stable, uses GDB's value
ordering and applies skip before limit. `apoc.map.groupByMulti(list, key)` keeps
all maps for each key, omitting absent/null keys.

Procedure arguments may reference the current query row. `YIELD` aliases and
`YIELD ... WHERE` filters are supported:

```cypher
MATCH (n:Person {name: 'Ada'})
CALL apoc.path.expandConfig(n, {
  relationshipFilter: 'KNOWS>', labelFilter: '-Blocked',
  minLevel: 1, maxLevel: 3, uniqueness: 'NODE_PATH', bfs: true
}) YIELD path WHERE length(path) > 1
RETURN path;
```

`apoc.path.expandConfig(start, config)` returns `path`;
`subgraphNodes(start, config)` returns `node`; `subgraphAll(start, config)`
returns `nodes, relationships`, including all live relationships between the
selected nodes. Start may be one node, a node ID or a list.

Supported traversal options: `minLevel`, `maxLevel`, `relationshipFilter`,
`labelFilter`, `bfs`, `uniqueness`, `limit`, `filterStartNode`, `optional`,
`endNodes`, `terminatorNodes`, `allowlistNodes`, `denylistNodes`.
Relationship filters support `R>`, `<R`, `R`, wildcard directions and `|`.
Label filters support `+` allow, `-` deny, `>` end, `/` terminate, `|` and compound
labels such as `A:B`. Uniqueness supports `NODE_GLOBAL`, `RELATIONSHIP_GLOBAL`,
`NODE_PATH`, `RELATIONSHIP_PATH` and `NONE` (requires finite `maxLevel`).
Subgraph procedures require `NODE_GLOBAL`. Sequences, recent/level uniqueness
and regex label filters are not implemented.

`apoc.meta.stats()` returns graph/token counts and per-label/type maps.
`apoc.meta.schema([config])` returns `value`, a schema map with labels,
properties, relationships and declared index/constraint flags.
`apoc.meta.data([config])` returns tabular property and relationship metadata.
Both use exact scans; omit `sample` or set it to `-1`. Random sampling is
explicitly rejected. Existing GDB type names are used for property types.

## Related articles

[Procedures, subqueries and parameters](../cypher/subqueries.md) · [Batched subqueries and logical interchange](../imports/interchange.md) · [Graph data science](../gds/README.md)
