Skip to content

exp-algo: add Triangle Count + Clustering Coefficient#114

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-triangle-count-clustering-coefficient
Draft

exp-algo: add Triangle Count + Clustering Coefficient#114
Copilot wants to merge 2 commits intomainfrom
copilot/add-triangle-count-clustering-coefficient

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

Adds per-node triangle counting and local clustering coefficient as experimental UDFs under flex.exp.*.

API

  • exp.triangleCount(neighbors, adjacencyMap) — counts triangles a node participates in by checking which pairs of its neighbors are mutually connected. O(d × d_max) per node.
  • exp.clusteringCoefficient(triangles, degree) — computes triangles / C(degree, 2). O(1), designed to compose with triangleCount.

Usage

MATCH (n)--(m)
WITH n, collect(DISTINCT toString(id(m))) AS nbs
WITH collect([toString(id(n)), nbs]) AS pairs
WITH flex.map.fromPairs(pairs) AS adj
UNWIND keys(adj) AS nodeId
WITH nodeId, adj[nodeId] AS neighbors, adj
WITH nodeId, neighbors,
     flex.exp.triangleCount(neighbors, adj) AS tc,
     size(neighbors) AS degree
RETURN nodeId, tc, flex.exp.clusteringCoefficient(tc, degree) AS cc
ORDER BY cc DESC

Changes

  • src/exp/triangleCount.js, src/exp/clusteringCoefficient.js — implementations
  • tests/exp/ — 13 integration + unit tests covering triangles, K4, star graphs, numeric IDs, partial adjacency maps, null/invalid inputs
  • docs/exp/ — per-function docs with syntax, examples, cost notes
  • docs/README.md — new Experimental Algorithms section

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 0.0.0.0.in-addr.arpa
    • Triggering command: /usr/bin/node node server.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>exp-algo: add Triangle Count + Clustering Coefficient</issue_title>
<issue_description>## Summary
Add experimental support for triangle counting and clustering coefficient metrics (local and/or global) under flex.exp.*.

Why

These metrics complement community detection and centrality work already under discussion, and they are not part of the currently documented FalkorDB built-ins.

Use cases

  • Fraud / sybil ring discovery
  • Social cohesion and trust analysis
  • Community-quality validation
  • Graph quality checks and local-density analysis

Suggested scope

  • Consider paired helpers such as triangleCount and clusteringCoefficient
  • Clarify whether outputs are per-node, graph-wide, or both
  • Add docs and integration tests
  • Note expected cost on dense graphs
    </issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: gkorland <753206+gkorland@users.noreply.github.com>
Copilot AI changed the title [WIP] Add experimental support for triangle counting and clustering coefficient metrics exp-algo: add Triangle Count + Clustering Coefficient Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exp-algo: add Triangle Count + Clustering Coefficient

2 participants