Skip to content

Add q226: detect circular ownership structures (#8) - #20

Open
chrisdebian wants to merge 1 commit into
openownership:mainfrom
chrisdebian:circular-ownership-detection
Open

Add q226: detect circular ownership structures (#8)#20
chrisdebian wants to merge 1 commit into
openownership:mainfrom
chrisdebian:circular-ownership-detection

Conversation

@chrisdebian

Copy link
Copy Markdown

Closes #8.

Adds q226(ownershipOrControlStatement) to qbods.py, following the existing qNNN function style (same pattern as #19 / q225).

It builds a directed graph of entity-to-entity ownership links (interestedParty → subject, restricted to rows where both ends are entities, since only an entity can be owned) and runs networkx.simple_cycles to find any closed ownership loops — e.g. A owns B, B owns A — which is banned under UK law per the Global Witness report linked in the issue.

Returns a list of two values: a dataframe with one row per circular ownership chain found (entities involved + chain length), and a summary dict with the total number of cycles and the number of distinct entities involved in at least one cycle.

Testing: verified against synthetic data — a 3-entity cycle (A→B→C→A) is correctly detected, a non-cyclic chain (X→Y) is correctly excluded, and person-owned rows are excluded from the graph entirely. As with #19, I don't have access to the real UK PSC BODS dataset locally (the csv/ folder is gitignored), so this hasn't been validated against real data — happy to adjust if real data surfaces an edge case.

Answers issue openownership#8 by building a directed graph of entity-to-entity
ownership links (interestedParty -> subject, restricted to rows
where both ends are entities, since only entities can be owned) and
running networkx's simple_cycles to find any closed ownership loops
(e.g. A owns B, B owns A), which are banned under UK law.
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.

Identifying circular ownership in BODS data

1 participant